fix: consider TM when evaluating permissions to join

seems like this check had gone missing
This commit is contained in:
Lukáš Tinkl 2024-03-27 13:46:18 +01:00 committed by Lukáš Tinkl
parent 5af2f28aa2
commit 255f318627
2 changed files with 11 additions and 14 deletions

View File

@ -367,7 +367,7 @@ proc createItemFromPublicKey(self: Module, publicKey: string): UserItem =
proc initContactRequestsModel(self: Module) =
var contactsWhoAddedMe: seq[UserItem]
let contacts = self.controller.getContacts(ContactsGroup.IncomingPendingContactRequests)
let contacts = self.controller.getContacts(ContactsGroup.IncomingPendingContactRequests)
for c in contacts:
let item = self.createItemFromPublicKey(c.id)
contactsWhoAddedMe.add(item)
@ -378,7 +378,7 @@ proc rebuildCommunityTokenPermissionsModel(self: Module) =
let community = self.controller.getMyCommunity()
var tokenPermissionsItems: seq[TokenPermissionItem] = @[]
for id, tokenPermission in community.tokenPermissions:
for _, tokenPermission in community.tokenPermissions:
let chats = community.getCommunityChats(tokenPermission.chatIds)
let tokenPermissionItem = buildTokenPermissionItem(tokenPermission, chats)
tokenPermissionsItems.add(tokenPermissionItem)
@ -388,12 +388,12 @@ proc rebuildCommunityTokenPermissionsModel(self: Module) =
proc reevaluateRequiresTokenPermissionToJoin(self: Module) =
let community = self.controller.getMyCommunity()
var hasBecomeMemberOrBecomeAdminPermissions = false
for id, tokenPermission in community.tokenPermissions:
if tokenPermission.`type` == TokenPermissionType.BecomeMember or tokenPermission.`type` == TokenPermissionType.BecomeAdmin:
hasBecomeMemberOrBecomeAdminPermissions = true
self.view.setRequiresTokenPermissionToJoin(hasBecomeMemberOrBecomeAdminPermissions)
var joinPermissionsChanged = false
for _, tokenPermission in community.tokenPermissions:
if tokenPermission.`type` == TokenPermissionType.BecomeMember or tokenPermission.`type` == TokenPermissionType.BecomeAdmin or tokenPermission.`type` == TokenPermissionType.BecomeTokenMaster:
joinPermissionsChanged = true
break
self.view.setRequiresTokenPermissionToJoin(joinPermissionsChanged)
proc initCommunityTokenPermissionsModel(self: Module, channelGroup: ChannelGroupDto) =
self.rebuildCommunityTokenPermissionsModel()
@ -1554,4 +1554,4 @@ method communityContainsChat*(self: Module, chatId: string): bool =
method openCommunityChatAndScrollToMessage*(self: Module, chatId: string, messageId: string) =
if chatId in self.chatContentModules:
self.setActiveItem(chatId)
self.chatContentModules[chatId].scrollToMessage(messageId)
self.chatContentModules[chatId].scrollToMessage(messageId)

View File

@ -42,11 +42,8 @@ proc initTokenPermissionItem*(
result.tokenCriteriaMet = tokenCriteriaMet
result.state = state
for tcItem in tokenCriteria:
result.tokenCriteria.addItem(tcItem)
for clItem in chatList:
result.chatList.addItem(clItem)
result.tokenCriteria.setItems(tokenCriteria)
result.chatList.setItems(chatList)
proc addTokenCriteria*(self: TokenPermissionItem, tokenCriteria: TokenCriteriaItem) =
self.tokenCriteria.addItem(tokenCriteria)