fix(JoinCommunityView): update amIMember state when kicked and joined
Also add handlers to JoinCommunityView for requesting and cancelling requests. These will be extended in follow up commits to included authentication modals
This commit is contained in:
parent
bef14365aa
commit
cc1a89efef
|
@ -253,6 +253,15 @@ proc init*(self: Controller) =
|
|||
self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT) do(e: Args):
|
||||
self.delegate.onWalletAccountTokensRebuilt()
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_KICKED) do (e: Args):
|
||||
let args = CommunityArgs(e)
|
||||
if (args.community.id == self.sectionId):
|
||||
self.delegate.onKickedFromCommunity()
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_JOINED) do (e: Args):
|
||||
let args = CommunityArgs(e)
|
||||
if (args.community.id == self.sectionId):
|
||||
self.delegate.onJoinedCommunity()
|
||||
|
||||
self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args):
|
||||
var args = ContactArgs(e)
|
||||
|
|
|
@ -358,3 +358,9 @@ method onCommunityTokenMetadataAdded*(self: AccessInterface, communityId: string
|
|||
|
||||
method onWalletAccountTokensRebuilt*(self: AccessInterface) =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onKickedFromCommunity*(self: AccessInterface) =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onJoinedCommunity*(self: AccessInterface) =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
|
@ -811,6 +811,12 @@ method onCommunityTokenMetadataAdded*(self: Module, communityId: string, tokenMe
|
|||
if tokenMetadata.tokenType == community_dto.TokenType.ERC20 and not self.view.tokenListModel().hasItem(tokenMetadata.symbol):
|
||||
self.view.tokenListModel.addItems(@[tokenListItem])
|
||||
|
||||
method onKickedFromCommunity*(self: Module) =
|
||||
self.view.setAmIMember(false)
|
||||
|
||||
method onJoinedCommunity*(self: Module) =
|
||||
self.view.setAmIMember(true)
|
||||
|
||||
method onMarkAllMessagesRead*(self: Module, chatId: string) =
|
||||
self.updateBadgeNotifications(chatId, hasUnreadMessages=false, unviewedMentionsCount=0)
|
||||
let chatDetails = self.controller.getChatDetails(chatId)
|
||||
|
|
|
@ -134,6 +134,7 @@ const SIGNAL_COMMUNITY_CHANNEL_CATEGORY_CHANGED* = "communityChannelCategoryChan
|
|||
const SIGNAL_COMMUNITY_MEMBER_APPROVED* = "communityMemberApproved"
|
||||
const SIGNAL_COMMUNITY_MEMBER_REMOVED* = "communityMemberRemoved"
|
||||
const SIGNAL_COMMUNITY_MEMBERS_CHANGED* = "communityMembersChanged"
|
||||
const SIGNAL_COMMUNITY_KICKED* = "communityKicked"
|
||||
const SIGNAL_NEW_REQUEST_TO_JOIN_COMMUNITY* = "newRequestToJoinCommunity"
|
||||
const SIGNAL_REQUEST_TO_JOIN_COMMUNITY_CANCELED* = "requestToJoinCommunityCanceled"
|
||||
const SIGNAL_CURATED_COMMUNITY_FOUND* = "curatedCommunityFound"
|
||||
|
@ -576,6 +577,8 @@ QtObject:
|
|||
self.events.emit(SIGNAL_COMMUNITY_JOINED, CommunityArgs(community: community, fromUserAction: false))
|
||||
|
||||
self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[community]))
|
||||
if wasJoined and not community.joined and not community.isMember:
|
||||
self.events.emit(SIGNAL_COMMUNITY_KICKED, CommunityArgs(community: community))
|
||||
|
||||
except Exception as e:
|
||||
error "Error handling community updates", msg = e.msg, communities, updatedChats, removedChats
|
||||
|
|
|
@ -66,6 +66,13 @@ StackLayout {
|
|||
assetsModel: root.rootStore.assetsModel
|
||||
collectiblesModel: root.rootStore.collectiblesModel
|
||||
isInvitationPending: root.rootStore.isCommunityRequestPending(communityData.id)
|
||||
onRevealAddressClicked: {
|
||||
root.rootStore.requestToJoinCommunity(communityData.id, root.rootStore.userProfileInst.name)
|
||||
}
|
||||
onInvitationPendingClicked: {
|
||||
root.rootStore.cancelPendingRequest(communityData.id)
|
||||
joinCommunityView.isInvitationPending = root.rootStore.isCommunityRequestPending(communityData.id)
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.rootStore.communitiesModuleInst
|
||||
|
|
Loading…
Reference in New Issue