From c85734f08d4f2e2454c67799b41f29cc7299b26c Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Tue, 1 Feb 2022 15:15:22 +0100 Subject: [PATCH] fix(@desktop/chat): group members count is wrong Fixes #4614 --- .../main/chat_section/chat_content/module.nim | 2 +- .../chat_content/users/controller.nim | 15 +++++++++------ .../chat_section/chat_content/users/module.nim | 6 ++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/app/modules/main/chat_section/chat_content/module.nim b/src/app/modules/main/chat_section/chat_content/module.nim index e60cc2d22b..760a5cf4d3 100644 --- a/src/app/modules/main/chat_section/chat_content/module.nim +++ b/src/app/modules/main/chat_section/chat_content/module.nim @@ -54,7 +54,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt result.messagesModule = messages_module.newModule(result, events, sectionId, chatId, belongsToCommunity, contactService, communityService, chatService, messageService, mailserversService) result.usersModule = users_module.newModule(result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable, - contactService, communityService, messageService) + contactService, chatService, communityService, messageService) method delete*(self: Module) = self.inputAreaModule.delete diff --git a/src/app/modules/main/chat_section/chat_content/users/controller.nim b/src/app/modules/main/chat_section/chat_content/users/controller.nim index bb86a024cc..e7ab79aae1 100644 --- a/src/app/modules/main/chat_section/chat_content/users/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/users/controller.nim @@ -21,12 +21,14 @@ type belongsToCommunity: bool isUsersListAvailable: bool #users list is not available for 1:1 chat contactService: contact_service.Service + chatService: chat_service.Service communityService: community_service.Service messageService: message_service.Service proc newController*(delegate: io_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string, belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service, - communityService: community_service.Service, messageService: message_service.Service): + chatService: chat_service.Service, communityService: community_service.Service, + messageService: message_service.Service): Controller = result = Controller() result.delegate = delegate @@ -36,6 +38,7 @@ proc newController*(delegate: io_interface.AccessInterface, events: EventEmitter result.belongsToCommunity = belongsToCommunity result.isUsersListAvailable = isUsersListAvailable result.contactService = contactService + result.chatService = chatService result.communityService = communityService result.messageService = messageService @@ -84,12 +87,12 @@ method init*(self: Controller) = self.delegate.onChatMembersAdded(@[args.pubKey]) method getMembersPublicKeys*(self: Controller): seq[string] = - # in case of 1:1 chat, there is no a members list if(not self.belongsToCommunity): - return - - let communityDto = self.communityService.getCommunityById(self.sectionId) - result = communityDto.members.map(x => x.id) + let chatDto = self.chatService.getChatById(self.chatId) + return chatDto.members.map(x => x.id) + else: + let communityDto = self.communityService.getCommunityById(self.sectionId) + return communityDto.members.map(x => x.id) method getContactNameAndImage*(self: Controller, contactId: string): tuple[name: string, image: string, isIdenticon: bool] = diff --git a/src/app/modules/main/chat_section/chat_content/users/module.nim b/src/app/modules/main/chat_section/chat_content/users/module.nim index 9cdaca8a7b..b4b10076ee 100644 --- a/src/app/modules/main/chat_section/chat_content/users/module.nim +++ b/src/app/modules/main/chat_section/chat_content/users/module.nim @@ -6,6 +6,7 @@ import ../../../../shared_models/[user_model, user_item] import ../../../../../global/global_singleton import ../../../../../core/eventemitter import ../../../../../../app_service/service/contacts/service as contact_service +import ../../../../../../app_service/service/chat/service as chat_service import ../../../../../../app_service/service/community/service as community_service import ../../../../../../app_service/service/message/service as message_service @@ -21,14 +22,15 @@ type proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string, belongsToCommunity: bool, isUsersListAvailable: bool, contactService: contact_service.Service, - communityService: community_service.Service, messageService: message_service.Service): + chatService: chat_service.Service, communityService: community_service.Service, + messageService: message_service.Service): Module = result = Module() result.delegate = delegate result.view = view.newView(result) result.viewVariant = newQVariant(result.view) result.controller = controller.newController(result, events, sectionId, chatId, belongsToCommunity, isUsersListAvailable, - contactService, communityService, messageService) + contactService, chatService, communityService, messageService) result.moduleLoaded = false method delete*(self: Module) =