fix(invitation-bubble): Adds loading state for unfurling links

Fixes: #10422
This commit is contained in:
Boris Melnik 2023-05-24 15:06:43 +03:00
parent 2f5a76db02
commit 92a9c41238
9 changed files with 37 additions and 5 deletions

View File

@ -52,6 +52,9 @@ proc init*(self: Controller) =
let args = CommunityArgs(e)
self.delegate.onImportCommunityErrorOccured(args.community.id, args.error)
self.events.on(SIGNAL_COMMUNITY_INFO_ALREADY_REQUESTED) do(e: Args):
self.delegate.communityInfoAlreadyRequested()
self.events.on(SIGNAL_CURATED_COMMUNITY_FOUND) do(e:Args):
let args = CommunityArgs(e)
self.delegate.curatedCommunityAdded(args.community)

View File

@ -159,3 +159,6 @@ method curatedCommunitiesLoadingFailed*(self: AccessInterface) {.base.} =
method curatedCommunitiesLoaded*(self: AccessInterface, curatedCommunities: seq[CommunityDto]) {.base.} =
raise newException(ValueError, "No implementation available")
method communityInfoAlreadyRequested*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -382,3 +382,5 @@ method discordImportProgressUpdated*(
method requestCancelDiscordCommunityImport*(self: Module, id: string) =
self.controller.requestCancelDiscordCommunityImport(id)
method communityInfoAlreadyRequested*(self: Module) =
self.view.communityInfoAlreadyRequested()

View File

@ -101,6 +101,7 @@ QtObject:
proc discordOldestMessageTimestampChanged*(self: View) {.signal.}
proc discordImportErrorsCountChanged*(self: View) {.signal.}
proc communityAccessRequested*(self: View, communityId: string) {.signal.}
proc communityInfoAlreadyRequested*(self: View) {.signal.}
proc communityTagsChanged*(self: View) {.signal.}

View File

@ -166,6 +166,8 @@ const SIGNAL_ACCEPT_REQUEST_TO_JOIN_LOADING* = "acceptRequestToJoinLoading"
const SIGNAL_ACCEPT_REQUEST_TO_JOIN_FAILED* = "acceptRequestToJoinFailed"
const SIGNAL_ACCEPT_REQUEST_TO_JOIN_FAILED_NO_PERMISSION* = "acceptRequestToJoinFailedNoPermission"
const SIGNAL_COMMUNITY_INFO_ALREADY_REQUESTED* = "communityInfoAlreadyRequested"
const TOKEN_PERMISSIONS_ADDED = "tokenPermissionsAdded"
const TOKEN_PERMISSIONS_MODIFIED = "tokenPermissionsModified"
@ -1453,6 +1455,7 @@ QtObject:
if communityId in self.requestedCommunityIds:
info "requestCommunityInfo: skipping as already requested", communityId
self.events.emit(SIGNAL_COMMUNITY_INFO_ALREADY_REQUESTED, Args())
return
self.requestedCommunityIds.incl(communityId)

View File

@ -76,6 +76,8 @@ QtObject {
signal importingCommunityStateChanged(string communityId, int state, string errorMsg)
signal communityInfoAlreadyRequested()
signal goToMembershipRequestsPage()
function setActiveCommunity(communityId) {
@ -615,6 +617,10 @@ QtObject {
function onImportingCommunityStateChanged(communityId, state, errorMsg) {
root.importingCommunityStateChanged(communityId, state, errorMsg)
}
function onCommunityInfoAlreadyRequested() {
root.communityInfoAlreadyRequested()
}
}
readonly property Connections mainModuleInstConnections: Connections {

View File

@ -249,5 +249,14 @@ Item {
Constants.ephemeralNotificationType.normal,
"")
}
function onCommunityInfoAlreadyRequested() {
Global.displayToastMessage(qsTr("Community data not loaded yet."),
qsTr("Please wait for the unfurl to show"),
"",
true,
Constants.ephemeralNotificationType.normal,
"")
}
}
}

View File

@ -15,11 +15,12 @@ import shared.popups 1.0
Control {
id: root
implicitWidth: d.invitedCommunity ? 270 /*by design*/ : 0
implicitWidth: d.invitedCommunity || loading ? 270 /*by design*/ : 0
padding: 1
property var store
property string communityId
property bool loading: false
QtObject {
id: d
@ -133,6 +134,8 @@ Control {
color: d.communityColor
isImage: true
}
visible: !root.loading
}
ColumnLayout {
@ -141,7 +144,7 @@ Control {
StatusBaseText {
Layout.fillWidth: true
text: d.communityName
text: root.loading ? qsTr("Community data not loaded yet.") : d.communityName
font.weight: Font.Bold
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font.pixelSize: 17
@ -151,7 +154,7 @@ Control {
StatusBaseText {
Layout.fillWidth: true
text: d.communityDescription
text: root.loading ? qsTr("Please wait for the unfurl to show") : d.communityDescription
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
color: Theme.palette.directColor1
}
@ -159,7 +162,7 @@ Control {
StatusBaseText {
Layout.fillWidth: true
text: qsTr("%n member(s)", "", d.communityNbMembers)
text: root.loading ? "" : qsTr("%n member(s)", "", d.communityNbMembers)
font.pixelSize: 13
font.weight: Font.Medium
color: Theme.palette.baseColor1
@ -180,6 +183,7 @@ Control {
Layout.preferredHeight: 44
text: qsTr("Go to Community")
loading: root.loading
radius: d.radius - 1 // We do -1, otherwise there's a gap between border and button
onClicked: {

View File

@ -190,7 +190,8 @@ Column {
store: root.store
communityId: invitationData ? invitationData.communityId : ""
anchors.left: parent.left
visible: !!invitationData && !invitationData.fetching
visible: !!invitationData
loading: invitationData.fetching
Connections {
enabled: !!invitationData && invitationData.fetching