From 057b6c2c0f61030055b1f7b50c1567362e53f77b Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 29 Aug 2023 14:21:37 -0400 Subject: [PATCH] fix: make sure we only get a community when it's a community Part of #11996 --- src/app/modules/main/activity_center/module.nim | 4 +++- .../chat_content/messages/module.nim | 17 ++++++++++++----- .../profile_section/notifications/module.nim | 2 -- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/app/modules/main/activity_center/module.nim b/src/app/modules/main/activity_center/module.nim index d97ff3d53c..4d0d152970 100644 --- a/src/app/modules/main/activity_center/module.nim +++ b/src/app/modules/main/activity_center/module.nim @@ -82,7 +82,9 @@ method hasUnseenActivityCenterNotificationsChanged*(self: Module) = proc createMessageItemFromDto(self: Module, message: MessageDto, communityId: string): MessageItem = let contactDetails = self.controller.getContactDetails(message.`from`) - let communityChats = self.controller.getCommunityById(communityId).chats + var communityChats: seq[ChatDto] = @[] + if communityId != singletonInstance.userProfile.getPubKey(): + communityChats = self.controller.getCommunityById(communityId).chats var quotedMessageAuthorDetails = ContactDetails() if message.quotedMessage.`from` != "": diff --git a/src/app/modules/main/chat_section/chat_content/messages/module.nim b/src/app/modules/main/chat_section/chat_content/messages/module.nim index 44721805bf..d2ed0c17c3 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/module.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/module.nim @@ -245,8 +245,9 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se else: quotedMessageAuthorDetails = self.controller.getContactDetails(message.quotedMessage.`from`) - var communityChats: seq[ChatDto] - communityChats = self.controller.getCommunityDetails().chats + var communityChats: seq[ChatDto] = @[] + if self.controller.belongsToCommunity(): + communityChats = self.controller.getCommunityDetails().chats var renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats) @@ -364,7 +365,9 @@ method messagesAdded*(self: Module, messages: seq[MessageDto]) = for message in messages: let sender = self.controller.getContactDetails(message.`from`) - let communityChats = self.controller.getCommunityDetails().chats + var communityChats: seq[ChatDto] = @[] + if self.controller.belongsToCommunity(): + communityChats = self.controller.getCommunityDetails().chats var quotedMessageAuthorDetails = ContactDetails() if message.quotedMessage.`from` != "": if(message.`from` == message.quotedMessage.`from`): @@ -593,7 +596,9 @@ method updateContactDetails*(self: Module, contactId: string) = item.quotedMessageAuthorAvatar = updatedContact.icon if item.messageContainsMentions and item.mentionedUsersPks.anyIt(it == contactId): - let communityChats = self.controller.getCommunityDetails().chats + var communityChats: seq[ChatDto] = @[] + if self.controller.belongsToCommunity(): + communityChats = self.controller.getCommunityDetails().chats item.messageText = self.controller.getRenderedText(item.parsedText, communityChats) method deleteMessage*(self: Module, messageId: string) = @@ -611,7 +616,9 @@ method onMessageEdited*(self: Module, message: MessageDto) = return let mentionedUsersPks = itemBeforeChange.mentionedUsersPks - let communityChats = self.controller.getCommunityDetails().chats + var communityChats: seq[ChatDto] = @[] + if self.controller.belongsToCommunity(): + communityChats = self.controller.getCommunityDetails().chats self.view.model().updateEditedMsg( message.id, diff --git a/src/app/modules/main/profile_section/notifications/module.nim b/src/app/modules/main/profile_section/notifications/module.nim index 447b0dd023..a2c57f0aba 100644 --- a/src/app/modules/main/profile_section/notifications/module.nim +++ b/src/app/modules/main/profile_section/notifications/module.nim @@ -141,8 +141,6 @@ method addChat*(self: Module, itemId: string) = if(ind != -1): return let chatDto = self.controller.getChatDetails(itemId) - if chatDto.chatType != ChatType.OneToOne and chatDto.chatType != ChatType.PrivateGroupChat: - return self.addChat(chatDto) method setName*(self: Module, itemId: string, name: string) =