mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-19 11:03:40 +00:00
parent
2718836589
commit
3d6c05a7d1
@ -555,16 +555,16 @@ method getChatIcon*(self: Module): string =
|
||||
return chatDto.icon
|
||||
|
||||
method amIChatAdmin*(self: Module): bool =
|
||||
if(not self.controller.belongsToCommunity()):
|
||||
if not self.controller.belongsToCommunity():
|
||||
let chatDto = self.controller.getChatDetails()
|
||||
for member in chatDto.members:
|
||||
if (member.id == singletonInstance.userProfile.getPubKey()):
|
||||
# TODO untangle this. There is no special roles for group chats
|
||||
return member.role == MemberRole.Owner or member.role == MemberRole.Admin or member.role == MemberRole.TokenMaster
|
||||
return false
|
||||
else:
|
||||
let communityDto = self.controller.getCommunityDetails()
|
||||
return communityDto.memberRole == MemberRole.Owner or
|
||||
communityDto.memberRole == MemberRole.Admin or communityDto.memberRole == MemberRole.TokenMaster
|
||||
return communityDto.isPrivilegedUser
|
||||
|
||||
method pinMessageAllowedForMembers*(self: Module): bool =
|
||||
if(self.controller.belongsToCommunity()):
|
||||
@ -734,8 +734,7 @@ method markMessagesAsRead*(self: Module, messages: seq[string]) =
|
||||
self.view.model().markAsSeen(messages)
|
||||
|
||||
method updateCommunityDetails*(self: Module, community: CommunityDto) =
|
||||
self.view.setAmIChatAdmin(community.memberRole == MemberRole.Owner or
|
||||
community.memberRole == MemberRole.Admin or community.memberRole == MemberRole.TokenMaster)
|
||||
self.view.setAmIChatAdmin(community.isPrivilegedUser)
|
||||
self.view.setIsPinMessageAllowedForMembers(community.adminSettings.pinMessageAllMembersEnabled)
|
||||
|
||||
proc setChatDetails(self: Module, chatDetails: ChatDto) =
|
||||
|
@ -350,10 +350,6 @@ method onChatsLoaded*(
|
||||
if chatId == activeChatId:
|
||||
cModule.onMadeActive()
|
||||
|
||||
if(self.controller.isCommunity()):
|
||||
let community = self.controller.getMyCommunity()
|
||||
self.controller.asyncCheckChannelPermissions(community.id, activeChatId)
|
||||
|
||||
self.view.chatsLoaded()
|
||||
|
||||
proc checkIfModuleDidLoad(self: Module) =
|
||||
@ -432,9 +428,10 @@ method activeItemSet*(self: Module, itemId: string) =
|
||||
self.delegate.onDeactivateChatLoader(deactivateSectionId, deactivateChatId)
|
||||
|
||||
if self.controller.isCommunity():
|
||||
let community = self.controller.getMyCommunity()
|
||||
if not community.isPrivilegedUser:
|
||||
self.controller.asyncCheckChannelPermissions(mySectionId, activeChatId)
|
||||
|
||||
|
||||
method getModuleAsVariant*(self: Module): QVariant =
|
||||
return self.viewVariant
|
||||
|
||||
@ -505,6 +502,8 @@ method onActiveSectionChange*(self: Module, sectionId: string) =
|
||||
self.setActiveItem(activeChatId)
|
||||
|
||||
if self.isCommunity():
|
||||
let community = self.controller.getMyCommunity()
|
||||
if not community.isPrivilegedUser:
|
||||
self.controller.asyncCheckPermissionsToJoin()
|
||||
self.controller.asyncCheckAllChannelsPermissions()
|
||||
|
||||
|
@ -567,3 +567,15 @@ proc getCommunityChats*(self: CommunityDto, chatsIds: seq[string]): seq[ChatDto]
|
||||
chats.add(communityChat)
|
||||
break
|
||||
return chats
|
||||
|
||||
proc isOwner*(self: CommunityDto): bool =
|
||||
return self.memberRole == MemberRole.Owner
|
||||
|
||||
proc isTokenMaster*(self: CommunityDto): bool =
|
||||
return self.memberRole == MemberRole.TokenMaster
|
||||
|
||||
proc isAdmin*(self: CommunityDto): bool =
|
||||
return self.memberRole == MemberRole.Admin
|
||||
|
||||
proc isPrivilegedUser*(self: CommunityDto): bool =
|
||||
return self.isControlNode or self.isOwner or self.isTokenMaster or self.isAdmin
|
||||
|
@ -23,6 +23,12 @@ StackLayout {
|
||||
|
||||
property var sectionItemModel
|
||||
|
||||
readonly property bool isOwner: community.memberRole === Constants.memberRole.owner
|
||||
readonly property bool isAdmin: community.memberRole === Constants.memberRole.admin
|
||||
readonly property bool isTokenMasterOwner: community.memberRole === Constants.memberRole.tokenMaster
|
||||
readonly property bool isControlNode: community.isControlNode
|
||||
readonly property bool isPrivilegedUser: isControlNode || isOwner || isAdmin || isTokenMasterOwner
|
||||
|
||||
property bool communitySettingsDisabled
|
||||
|
||||
property var emojiPopup
|
||||
@ -153,7 +159,7 @@ StackLayout {
|
||||
|
||||
Loader {
|
||||
id: communitySettingsLoader
|
||||
active: root.rootStore.chatCommunitySectionModule.isCommunity()
|
||||
active: root.rootStore.chatCommunitySectionModule.isCommunity() && root.isPrivilegedUser
|
||||
|
||||
sourceComponent: CommunitySettingsView {
|
||||
id: communitySettingsView
|
||||
|
Loading…
x
Reference in New Issue
Block a user