fix(permissions): ensure permissions model is rebuilt when permission

was deleted

This is needed because there's cases where the deletion of a permission
might cause the current user to no longer be eligible to join
a community.

Community has the follwoing permissions:
- own 2 ETH and 1 FOO_NFT or
- own 1 FOO_NFT

User owns: 1 FOO_NFT

^ The above would make the user eligible to request access to join.

Now if the community removes the second permission, the user now no
longer fulfills the requirements so we need to ensure the UI
permits the user to request access.

Rebuilding the permissions model (including its token criteria) sets the
necessary flags in the UI automatically.
This commit is contained in:
Pascal Precht 2023-03-30 14:10:32 +02:00 committed by Follow the white rabbit
parent dbef72be01
commit 90acfa0457
2 changed files with 2 additions and 2 deletions

View File

@ -771,8 +771,7 @@ method onChatUnmuted*(self: Module, chatId: string) =
self.view.chatsModel().changeMutedOnItemById(chatId, muted=false)
method onCommunityTokenPermissionDeleted*(self: Module, communityId: string, permissionId: string) =
self.view.tokenPermissionsModel().removeItemWithId(permissionId)
self.view.setRequiresTokenPermissionToJoin(self.view.tokenPermissionsModel().getCount() > 0)
self.rebuildCommunityTokenPermissionsModel()
singletonInstance.globalEvents.showCommunityTokenPermissionDeletedNotification(communityId, "Community permission deleted", "A token permission has been removed")
method onCommunityTokenPermissionCreated*(self: Module, communityId: string, tokenPermission: CommunityTokenPermissionDto) =

View File

@ -553,6 +553,7 @@ QtObject:
elif community.tokenPermissions.len < prev_community.tokenPermissions.len:
for id, prvTokenPermission in prev_community.tokenPermissions:
if not community.tokenPermissions.hasKey(id):
self.communities[community.id].tokenPermissions.del(id)
self.events.emit(SIGNAL_COMMUNITY_TOKEN_PERMISSION_DELETED,
CommunityTokenPermissionRemovedArgs(communityId: community.id, permissionId: id))