mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-29 05:30:09 +00:00
ios: fix switching to another chat prevents marking items as unread (#4652)
This commit is contained in:
@@ -910,6 +910,12 @@ final class Chat: ObservableObject, Identifiable, ChatLike {
|
||||
chatStats: chatStats ?? self.chatStats
|
||||
)
|
||||
}
|
||||
|
||||
func copyFrom(_ c: Chat) {
|
||||
self.chatInfo = c.chatInfo
|
||||
self.chatItems = c.chatItems
|
||||
self.chatStats = c.chatStats
|
||||
}
|
||||
|
||||
var userCanSend: Bool {
|
||||
switch chatInfo {
|
||||
|
||||
@@ -21,6 +21,7 @@ struct ChatView: View {
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
@Environment(\.scenePhase) var scenePhase
|
||||
// chat cannot be assigned, as it breaks observation in chat items
|
||||
@State @ObservedObject var chat: Chat
|
||||
@StateObject private var scrollModel = ReverseListScrollModel<ChatItem>()
|
||||
@StateObject private var floatingButtonModel = FloatingButtonModel()
|
||||
@@ -141,7 +142,8 @@ struct ChatView: View {
|
||||
if let cId {
|
||||
selectedChatItems = nil
|
||||
if let c = chatModel.getChat(cId) {
|
||||
chat = c
|
||||
// chat cannot be assigned, as it breaks observation in chat items
|
||||
chat.copyFrom(c)
|
||||
}
|
||||
initChatView()
|
||||
theme = buildTheme()
|
||||
@@ -407,7 +409,8 @@ struct ChatView: View {
|
||||
}
|
||||
.onChange(of: chatModel.chatId) { chatId in
|
||||
if let chatId, let c = chatModel.getChat(chatId) {
|
||||
chat = c
|
||||
// chat cannot be assigned, as it breaks observation in chat items
|
||||
chat.copyFrom(c)
|
||||
showChatInfoSheet = false
|
||||
loadChat(chat: c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user