mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 22:18:29 +00:00
android, desktop: fix chat preview and unread counter updating wrong chat
ChatsContext has two live instances: the primary chat list and the
secondary context used by the reports and member support views.
In addChatItem the chat index is resolved against the receiver context
(getChatIndex reads this.chats), but the list being read and written was
chatsContext.chats - always the primary singleton. On the secondary
context the two lists hold different chats in a different order, so the
index pointed at an unrelated chat in the main list, which then received
the last message preview, the unread increment and the pop to the top.
Use the receiver context's own list, as every other method in the class
already does. This reverts the unintended part of b97e1e0f1 and keeps its
memberPending guard.
This commit is contained in:
+4
-4
@@ -533,7 +533,7 @@ object ChatModel {
|
||||
val i = getChatIndex(rhId, cInfo.id)
|
||||
val chat: Chat
|
||||
if (i >= 0) {
|
||||
chat = chatsContext.chats[i]
|
||||
chat = chats[i]
|
||||
// update preview (for chat from main scope to show new items for invitee in pending status)
|
||||
if (cInfo.groupChatScope() == null || cInfo.groupInfo_?.membership?.memberPending == true) {
|
||||
val newPreviewItem = when (cInfo) {
|
||||
@@ -553,7 +553,7 @@ object ChatModel {
|
||||
else -> cItem
|
||||
}
|
||||
val wasUnread = chat.unreadTag
|
||||
chatsContext.chats[i] = chat.copy(
|
||||
chats[i] = chat.copy(
|
||||
chatItems = arrayListOf(newPreviewItem),
|
||||
chatStats =
|
||||
if (cItem.meta.itemStatus is CIStatus.RcvNew) {
|
||||
@@ -562,11 +562,11 @@ object ChatModel {
|
||||
} else
|
||||
chat.chatStats
|
||||
)
|
||||
updateChatTagReadInPrimaryContext(chatsContext.chats[i], wasUnread)
|
||||
updateChatTagReadInPrimaryContext(chats[i], wasUnread)
|
||||
}
|
||||
// pop chat
|
||||
if (appPlatform.isDesktop && cItem.chatDir.sent) {
|
||||
reorderChat(chatsContext.chats[i], 0)
|
||||
reorderChat(chats[i], 0)
|
||||
} else {
|
||||
popChatCollector.throttlePopChat(chat.remoteHostId, chat.id, currentPosition = i)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user