fix(Communities): ensure members count is updated when owner leaves community

When an owner of a community leaves its own community, we optimistically update the
members list in Status Desktop. The `LeaveCommunity` API that is called via status-lib
has been updated to correctly remove that member as well.

This depends on https://github.com/status-im/status-go/pull/2429

Fixes #4074
This commit is contained in:
Pascal Precht 2021-11-12 11:28:50 +01:00 committed by r4bbit.eth
parent 23b72a9e8d
commit 14f75692c4
2 changed files with 5 additions and 0 deletions

View File

@ -136,6 +136,7 @@ QtObject:
proc setPubKey*(self: ChatsView, pubKey: string) =
self.pubKey = pubKey
self.messageView.pubKey = pubKey
self.communities.pubKey = pubKey
proc getFormatInput(self: ChatsView): QVariant {.slot.} = newQVariant(self.formatInputView)
QtProperty[QVariant] formatInputView:

View File

@ -41,6 +41,7 @@ QtObject:
myCommunityRequests*: seq[CommunityMembershipRequest]
importingCommunityState: CommunityImportState
communityImportingProcessId: string
pubKey*: string
proc setup(self: CommunitiesView) =
self.QObject.setup
@ -60,6 +61,7 @@ QtObject:
result.observedCommunity = newCommunityItemView(status)
result.communityList = newCommunityList(status)
result.joinedCommunityList = newCommunityList(status)
result.pubKey = ""
result.setup
proc importingCommunityStateChanged*(self: CommunitiesView, state: int, communityImportingProcessId: string) {.signal.}
@ -390,6 +392,8 @@ QtObject:
self.joinedCommunitiesChanged()
var updatedCommunity = self.communityList.getCommunityById(communityId)
updatedCommunity.joined = false
let i = updatedCommunity.members.find(self.pubKey)
updatedCommunity.members.delete(i)
self.communityList.replaceCommunity(updatedCommunity)
self.communitiesChanged()
self.communityChanged(communityId)