fix(JoinCommunity): Unable to join community

Fixes #12351
This commit is contained in:
Noelia 2023-10-05 14:28:58 +02:00 committed by Noelia
parent f5b767ec15
commit fd1e6ac657
1 changed files with 18 additions and 16 deletions

View File

@ -57,6 +57,9 @@ Item {
readonly property bool showJoinButton: !communityData.joined || root.communityData.amIBanned readonly property bool showJoinButton: !communityData.joined || root.communityData.amIBanned
readonly property bool showFinaliseOwnershipButton: root.isPendingOwnershipRequest readonly property bool showFinaliseOwnershipButton: root.isPendingOwnershipRequest
property bool invitationPending: root.store.isCommunityRequestPending(communityData.id)
property bool isJoinBtnLoading: false
} }
ColumnHeaderPanel { ColumnHeaderPanel {
@ -84,12 +87,13 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
sourceComponent: d.showFinaliseOwnershipButton ? finaliseCommunityOwnershipBtn : sourceComponent: d.showFinaliseOwnershipButton ? finaliseCommunityOwnershipBtn :
d.showJoinButton ? joinCommunityButton : undefined d.showJoinButton ? joinCommunityButton : undefined
active: d.showFinaliseOwnershipButton || d.showJoinButton
} }
ChatsLoadingPanel { ChatsLoadingPanel {
chatSectionModule: root.communitySectionModule chatSectionModule: root.communitySectionModule
width: parent.width width: parent.width
anchors.top: columnHeaderButton.sourceComponent !== undefined ? columnHeaderButton.bottom : communityHeader.bottom anchors.top: columnHeaderButton.active ? columnHeaderButton.bottom : communityHeader.bottom
anchors.topMargin: active ? Style.current.halfPadding : 0 anchors.topMargin: active ? Style.current.halfPadding : 0
} }
@ -143,7 +147,7 @@ Item {
StatusScrollView { StatusScrollView {
id: scrollView id: scrollView
anchors.top: columnHeaderButton.sourceComponent !== undefined ? columnHeaderButton.bottom : communityHeader.bottom anchors.top: columnHeaderButton.active ? columnHeaderButton.bottom : communityHeader.bottom
anchors.topMargin: Style.current.halfPadding anchors.topMargin: Style.current.halfPadding
anchors.bottom: createChatOrCommunity.top anchors.bottom: createChatOrCommunity.top
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -456,18 +460,16 @@ Item {
id: joinCommunityButton id: joinCommunityButton
StatusButton { StatusButton {
property bool invitationPending: root.store.isCommunityRequestPending(communityData.id)
anchors.top: communityHeader.bottom anchors.top: communityHeader.bottom
anchors.topMargin: Style.current.halfPadding anchors.topMargin: Style.current.halfPadding
anchors.bottomMargin: Style.current.halfPadding anchors.bottomMargin: Style.current.halfPadding
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
enabled: !root.communityData.amIBanned enabled: !root.communityData.amIBanned
loading: d.isJoinBtnLoading
text: { text: {
if (root.communityData.amIBanned) return qsTr("You were banned from community") if (root.communityData.amIBanned) return qsTr("You were banned from community")
if (invitationPending) return qsTr("Membership request pending...") if (d.invitationPending) return qsTr("Membership request pending...")
return root.communityData.access === Constants.communityChatOnRequestAccess ? return root.communityData.access === Constants.communityChatOnRequestAccess ?
qsTr("Request to join") : qsTr("Join Community") qsTr("Request to join") : qsTr("Join Community")
@ -478,18 +480,18 @@ Item {
} }
Connections { Connections {
enabled: joinCommunityButton.loading enabled: d.isJoinBtnLoading
target: root.store.communitiesModuleInst target: root.store.communitiesModuleInst
function onCommunityAccessRequested(communityId: string) { function onCommunityAccessRequested(communityId: string) {
if (communityId === communityData.id) { if (communityId === communityData.id) {
joinCommunityButton.invitationPending = root.store.isCommunityRequestPending(communityData.id) d.invitationPending = root.store.isCommunityRequestPending(communityData.id)
joinCommunityButton.loading = false d.isJoinBtnLoading = false
} }
} }
function onCommunityAccessFailed(communityId: string) { function onCommunityAccessFailed(communityId: string) {
if (communityId === communityData.id) { if (communityId === communityData.id) {
joinCommunityButton.invitationPending = false d.invitationPending = false
joinCommunityButton.loading = false d.isJoinBtnLoading = false
Global.displayToastMessage(qsTr("Request to join failed"), Global.displayToastMessage(qsTr("Request to join failed"),
qsTr("Please try again later"), qsTr("Please try again later"),
"", "",
@ -499,8 +501,8 @@ Item {
} }
} }
function onUserAuthenticationCanceled() { function onUserAuthenticationCanceled() {
joinCommunityButton.invitationPending = false d.invitationPending = false
joinCommunityButton.loading = false d.isJoinBtnLoading = false
} }
} }
@ -508,7 +510,7 @@ Item {
id: communityIntroDialog id: communityIntroDialog
CommunityIntroDialog { CommunityIntroDialog {
isInvitationPending: joinCommunityButton.invitationPending isInvitationPending: d.invitationPending
requirementsCheckPending: root.store.requirementsCheckPending requirementsCheckPending: root.store.requirementsCheckPending
name: communityData.name name: communityData.name
introMessage: communityData.introMessage introMessage: communityData.introMessage
@ -524,12 +526,12 @@ Item {
collectiblesModel: root.store.collectiblesModel collectiblesModel: root.store.collectiblesModel
onJoined: { onJoined: {
joinCommunityButton.loading = true d.isJoinBtnLoading = true
root.store.requestToJoinCommunityWithAuthentication(communityData.id, root.store.userProfileInst.name, sharedAddresses, airdropAddress) root.store.requestToJoinCommunityWithAuthentication(communityData.id, root.store.userProfileInst.name, sharedAddresses, airdropAddress)
} }
onCancelMembershipRequest: { onCancelMembershipRequest: {
root.store.cancelPendingRequest(communityData.id) root.store.cancelPendingRequest(communityData.id)
joinCommunityButton.invitationPending = root.store.isCommunityRequestPending(communityData.id) d.invitationPending = root.store.isCommunityRequestPending(communityData.id)
} }
onSharedAddressesUpdated: { onSharedAddressesUpdated: {
root.store.updatePermissionsModel(communityData.id, sharedAddresses) root.store.updatePermissionsModel(communityData.id, sharedAddresses)