feature(@desktop/chat): support jumping to search result message that is not currently loaded in memory
A crash leaving chat is fixed. The issue was very hidden cause everything looks ok, at first glance, but not, the thing is that "messages" exposed to qml were deleted from ChatsView and signals beginRemoveRows and endRemoveRows were emitted for CatsView abstract list model instead for MessageView abstract list model. That results in an app crash in some moments (not always reproducible, but often). Fixes: #3005
This commit is contained in:
parent
83d6817f70
commit
5e569865e4
|
@ -300,12 +300,7 @@ QtObject:
|
|||
|
||||
proc removeChat*(self: ChatsView, chatId: string) =
|
||||
discard self.channelView.chats.removeChatItemFromList(chatId)
|
||||
if (self.messageView.messageList.hasKey(chatId)):
|
||||
let index = self.messageView.getMessageListIndexById(chatId)
|
||||
self.beginRemoveRows(newQModelIndex(), index, index)
|
||||
self.messageView.messageList[chatId].delete
|
||||
self.messageView.messageList.del(chatId)
|
||||
self.endRemoveRows()
|
||||
self.messageView.removeChat(chatId)
|
||||
|
||||
proc toggleReaction*(self: ChatsView, messageId: string, emojiId: int) {.slot.} =
|
||||
if self.channelView.activeChannel.id == status_utils.getTimelineChatId():
|
||||
|
|
|
@ -431,6 +431,19 @@ QtObject:
|
|||
if (message.id == messageId):
|
||||
return chatId
|
||||
|
||||
proc removeChat*(self: MessageView, chatId: string) =
|
||||
if (not self.messageList.hasKey(chatId)):
|
||||
return
|
||||
|
||||
let index = self.getMessageListIndexById(chatId)
|
||||
if (index < 0 or index >= self.messageList.len):
|
||||
return
|
||||
|
||||
self.beginRemoveRows(newQModelIndex(), index, index)
|
||||
self.messageList[chatId].delete
|
||||
self.messageList.del(chatId)
|
||||
self.endRemoveRows()
|
||||
|
||||
proc getSearchResultMessageModel*(self: MessageView): QVariant {.slot.} =
|
||||
newQVariant(self.searchResultMessageModel)
|
||||
|
||||
|
|
Loading…
Reference in New Issue