fix(@desktop/chat): group members count is wrong

Fixes #4614
This commit is contained in:
Sale Djenic 2022-02-01 15:15:22 +01:00 committed by saledjenic
parent add8163f31
commit c85734f08d
3 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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] =

View File

@ -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) =