mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-25 20:44:38 +00:00
better updateChats
This commit is contained in:
@@ -298,7 +298,11 @@ final class ChatModel: ObservableObject {
|
||||
chat.chatItems = c.chatItems
|
||||
chat.chatStats = c.chatStats
|
||||
if i != j {
|
||||
chatsToPop.insert(c.chatInfo.id)
|
||||
if chatId != c.chatInfo.id {
|
||||
popChat_(j, to: i)
|
||||
} else if i == 0 {
|
||||
chatsToPop.insert(c.chatInfo.id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addChat(Chat(c), at: i)
|
||||
@@ -672,6 +676,11 @@ final class ChatModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
private func popChat_(_ i: Int, to position: Int = 0) {
|
||||
let chat = chats.remove(at: i)
|
||||
chats.insert(chat, at: position)
|
||||
}
|
||||
|
||||
private func markChatItemRead_(_ i: Int) {
|
||||
let meta = im.reversedChatItems[i].meta
|
||||
if case .rcvNew = meta.itemStatus {
|
||||
|
||||
Reference in New Issue
Block a user