fix(@desktop/chat): Fix referencing message nil pointer

Fix #13812
This commit is contained in:
Michal Iskierko 2024-03-07 12:56:15 +01:00 committed by Jonathan Rainville
parent 896b9f487d
commit 130d3e3336
1 changed files with 4 additions and 0 deletions

View File

@ -439,6 +439,8 @@ method toggleReaction*(self: Module, messageId: string, emojiId: int) =
var emojiIdAsEnum: EmojiId
if(message_reaction_item.toEmojiIdAsEnum(emojiId, emojiIdAsEnum)):
let item = self.view.model().getItemWithMessageId(messageId)
if(item.isNil):
return
let myPublicKey = singletonInstance.userProfile.getPubKey()
if(item.shouldAddReaction(emojiIdAsEnum, myPublicKey)):
self.controller.addReaction(messageId, emojiId)
@ -569,6 +571,8 @@ method onMessageDeleted*(self: Module, messageId, deletedBy: string) =
if deletedBy == "":
# deletedBy is empty if it was deleted by the sender
let messageItem = self.view.model().getItemWithMessageId(messageId)
if(messageItem.isNil):
return
if messageItem.id == "":
return
deletedByValue = messageItem.senderId