fix: make sure we only get a community when it's a community

Part of #11996
This commit is contained in:
Jonathan Rainville 2023-08-29 14:21:37 -04:00
parent 3d6c05a7d1
commit 057b6c2c0f
3 changed files with 15 additions and 8 deletions

View File

@ -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` != "":

View File

@ -245,7 +245,8 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
else:
quotedMessageAuthorDetails = self.controller.getContactDetails(message.quotedMessage.`from`)
var communityChats: seq[ChatDto]
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,

View File

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