parent
b257ccc87d
commit
354bd3e923
|
@ -45,7 +45,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
|
|||
belongsToCommunity: bool, isUsersListAvailable: bool, settingsService: settings_service.Service,
|
||||
nodeConfigurationService: node_configuration_service.Service, contactService: contact_service.Service, chatService: chat_service.Service,
|
||||
communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service,
|
||||
mailserversService: mailservers_service.Service, communityUsersModule: users_module.AccessInterface):
|
||||
mailserversService: mailservers_service.Service):
|
||||
Module =
|
||||
result = Module()
|
||||
result.delegate = delegate
|
||||
|
@ -59,11 +59,8 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
|
|||
chatService, communityService, gifService, messageService)
|
||||
result.messagesModule = messages_module.newModule(result, events, sectionId, chatId, belongsToCommunity,
|
||||
contactService, communityService, chatService, messageService, mailserversService)
|
||||
result.usersModule =
|
||||
if communityUsersModule == nil:
|
||||
users_module.newModule( events, sectionId, chatId, belongsToCommunity,
|
||||
isUsersListAvailable, contactService, chat_service, communityService, messageService)
|
||||
else: communityUsersModule
|
||||
result.usersModule = users_module.newModule(events, sectionId, chatId, belongsToCommunity,
|
||||
isUsersListAvailable, contactService, chat_service, communityService, messageService)
|
||||
|
||||
method delete*(self: Module) =
|
||||
self.controller.delete
|
||||
|
|
|
@ -134,13 +134,13 @@ proc init*(self: Controller) =
|
|||
if (self.belongsToCommunity):
|
||||
self.handleCommunityOnlyConnections()
|
||||
|
||||
proc belongsToCommunity*(self: Controller): bool =
|
||||
self.belongsToCommunity
|
||||
|
||||
proc getChat*(self: Controller): ChatDto =
|
||||
return self.chatService.getChatById(self.chatId)
|
||||
|
||||
proc getChatMembers*(self: Controller): seq[ChatMember] =
|
||||
if self.belongsToCommunity:
|
||||
return self.communityService.getCommunityById(self.sectionId).members
|
||||
|
||||
return self.chatService.getChatById(self.chatId).members
|
||||
|
||||
proc getContactNameAndImage*(self: Controller, contactId: string):
|
||||
|
|
|
@ -98,7 +98,7 @@ proc addChatMember(self: Module, member: ChatMember) =
|
|||
if member.id == "":
|
||||
return
|
||||
|
||||
if not member.joined:
|
||||
if not self.controller.belongsToCommunity() and not member.joined:
|
||||
if self.view.model().isContactWithIdAdded(member.id):
|
||||
# Member is no longer joined
|
||||
self.view.model().removeItemById(member.id)
|
||||
|
|
|
@ -340,9 +340,6 @@ method contactsStatusUpdated*(self: AccessInterface, statusUpdates: seq[StatusUp
|
|||
method switchToChannel*(self: AccessInterface, channelName: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method joinSpectatedCommunity*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method createOrEditCommunityTokenPermission*(self: AccessInterface, communityId: string, permissionId: string, permissionType: int, tokenCriteriaJson: string, channelIDs: seq[string], isPrivate: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ type
|
|||
chatContentModules: OrderedTable[string, chat_content_module.AccessInterface]
|
||||
moduleLoaded: bool
|
||||
chatsLoaded: bool
|
||||
usersModule: users_module.AccessInterface
|
||||
|
||||
# Forward declaration
|
||||
proc buildChatSectionUI(self: Module,
|
||||
|
@ -114,12 +113,6 @@ proc newModule*(
|
|||
|
||||
result.chatContentModules = initOrderedTable[string, chat_content_module.AccessInterface]()
|
||||
|
||||
# Simple community channels uses comminity usersModule while chats uses their own usersModule
|
||||
if isCommunity:
|
||||
result.usersModule = users_module.newModule(
|
||||
events, sectionId, chatId = "", belongsToCommunity = true, isUsersListAvailable = true,
|
||||
contactService, chat_service, communityService, messageService)
|
||||
|
||||
method delete*(self: Module) =
|
||||
self.controller.delete
|
||||
self.view.delete
|
||||
|
@ -127,8 +120,6 @@ method delete*(self: Module) =
|
|||
for cModule in self.chatContentModules.values:
|
||||
cModule.delete
|
||||
self.chatContentModules.clear
|
||||
if self.usersModule != nil:
|
||||
self.usersModule.delete
|
||||
|
||||
method isCommunity*(self: Module): bool =
|
||||
return self.controller.isCommunity()
|
||||
|
@ -153,7 +144,7 @@ proc addSubmodule(self: Module, chatId: string, belongToCommunity: bool, isUsers
|
|||
mailserversService: mailservers_service.Service) =
|
||||
self.chatContentModules[chatId] = chat_content_module.newModule(self, events, self.controller.getMySectionId(), chatId,
|
||||
belongToCommunity, isUsersListAvailable, settingsService, nodeConfigurationService, contactService, chatService, communityService,
|
||||
messageService, gifService, mailserversService, self.usersModule)
|
||||
messageService, gifService, mailserversService)
|
||||
|
||||
proc removeSubmodule(self: Module, chatId: string) =
|
||||
if(not self.chatContentModules.contains(chatId)):
|
||||
|
@ -352,7 +343,6 @@ method onChatsLoaded*(
|
|||
# we do this only in case of chat section (not in case of communities)
|
||||
self.initContactRequestsModel()
|
||||
else:
|
||||
self.usersModule.load()
|
||||
let community = self.controller.getMyCommunity()
|
||||
self.view.setAmIMember(community.joined)
|
||||
self.initCommunityTokenPermissionsModel(channelGroup)
|
||||
|
@ -1279,10 +1269,6 @@ method contactsStatusUpdated*(self: Module, statusUpdates: seq[StatusUpdateDto])
|
|||
let status = toOnlineStatus(s.statusType)
|
||||
self.view.chatsModel().updateItemOnlineStatusById(s.publicKey, status)
|
||||
|
||||
method joinSpectatedCommunity*(self: Module) =
|
||||
if self.usersModule != nil:
|
||||
self.usersModule.updateMembersList()
|
||||
|
||||
method createOrEditCommunityTokenPermission*(self: Module, communityId: string, permissionId: string, permissionType: int, tokenCriteriaJson: string, channelIDs: seq[string], isPrivate: bool) =
|
||||
|
||||
var tokenPermission = CommunityTokenPermissionDto()
|
||||
|
|
|
@ -163,8 +163,9 @@ QtObject:
|
|||
if (chatDto.active):
|
||||
chats.add(chatDto)
|
||||
|
||||
# Handling members update
|
||||
if self.chats.hasKey(chatDto.id) and self.chats[chatDto.id].members != chatDto.members:
|
||||
# Handling members update for non-community chats
|
||||
let isCommunityChat = chatDto.chatType == ChatType.CommunityChat
|
||||
if not isCommunityChat and self.chats.hasKey(chatDto.id) and self.chats[chatDto.id].members != chatDto.members:
|
||||
self.events.emit(SIGNAL_CHAT_MEMBERS_CHANGED, ChatMembersChangedArgs(chatId: chatDto.id, members: chatDto.members))
|
||||
self.updateOrAddChat(chatDto)
|
||||
|
||||
|
@ -354,6 +355,15 @@ QtObject:
|
|||
self.channelGroups[channelGroup.id] = newChannelGroup
|
||||
for chat in newChannelGroup.chats:
|
||||
self.updateOrAddChat(chat)
|
||||
|
||||
proc updateChannelMembers*(self: Service, channel: ChatDto) =
|
||||
if not self.chats.hasKey(channel.id):
|
||||
return
|
||||
|
||||
var chat = self.chats[channel.id]
|
||||
chat.members = channel.members
|
||||
self.updateOrAddChat(chat)
|
||||
self.events.emit(SIGNAL_CHAT_MEMBERS_CHANGED, ChatMembersChangedArgs(chatId: chat.id, members: chat.members))
|
||||
|
||||
proc getChannelGroupById*(self: Service, channelGroupId: string): ChannelGroupDto =
|
||||
if not self.channelGroups.contains(channelGroupId):
|
||||
|
|
|
@ -362,6 +362,7 @@ QtObject:
|
|||
chatDto.position = chat.position
|
||||
chatDto.canPost = chat.canPost
|
||||
chatDto.categoryId = chat.categoryId
|
||||
chatDto.members = chat.members
|
||||
|
||||
proc findChatById(id: string, chats: seq[ChatDto]): ChatDto =
|
||||
for chat in chats:
|
||||
|
@ -558,6 +559,10 @@ QtObject:
|
|||
let data = CommunityChatArgs(chat: updatedChat)
|
||||
self.events.emit(SIGNAL_COMMUNITY_CHANNEL_EDITED, data)
|
||||
|
||||
# Handle channel members update
|
||||
if chat.members != prev_chat.members:
|
||||
self.chatService.updateChannelMembers(chat)
|
||||
|
||||
# members list was changed
|
||||
if (community.isMember or community.tokenPermissions.len == 0) and community.members != prev_community.members:
|
||||
self.events.emit(SIGNAL_COMMUNITY_MEMBERS_CHANGED,
|
||||
|
|
|
@ -144,14 +144,7 @@ StatusSectionLayout {
|
|||
anchors.fill: parent
|
||||
store: root.rootStore
|
||||
label: qsTr("Members")
|
||||
usersModel: {
|
||||
let chatContentModule = root.rootStore.currentChatContentModule()
|
||||
if (!chatContentModule || !chatContentModule.usersModule) {
|
||||
// New communities have no chats, so no chatContentModule
|
||||
return null
|
||||
}
|
||||
return chatContentModule.usersModule.model
|
||||
}
|
||||
usersModel: root.chatContentModule && root.chatContentModule.usersModule ? root.chatContentModule.usersModule.model : null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue