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 57c26582ce..d171d6feed 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 @@ -47,6 +47,20 @@ proc newController*( method delete*(self: Controller) = discard +method handleCommunityOnlyConnections(self: Controller) = + self.events.on(SIGNAL_COMMUNITY_MEMBER_APPROVED) do(e: Args): + let args = CommunityMemberArgs(e) + if (args.communityId == self.sectionId): + self.delegate.onChatMembersAdded(@[args.pubKey]) + + self.events.on(SIGNAL_COMMUNITIES_UPDATE) do(e:Args): + let args = CommunitiesArgs(e) + for community in args.communities: + if (community.id != self.sectionId): + continue + let membersPubKeys = community.members.map(x => x.id) + self.delegate.onChatMembersAdded(membersPubKeys) + method init*(self: Controller) = # TODO call this function again if isUsersListAvailable changes if(self.isUsersListAvailable): @@ -88,10 +102,7 @@ method init*(self: Controller) = self.delegate.onChatMemberUpdated(args.id, args.admin, args.joined) if (self.belongsToCommunity): - self.events.on(SIGNAL_COMMUNITY_MEMBER_APPROVED) do(e: Args): - let args = CommunityMemberArgs(e) - if (args.communityId == self.sectionId): - self.delegate.onChatMembersAdded(@[args.pubKey]) + self.handleCommunityOnlyConnections() self.events.on(SIGNAL_COMMUNITY_MEMBER_REMOVED) do(e: Args): let args = CommunityMemberArgs(e)