ios: optimize performance of updating chats (#4723)

* ios: optimize performance of updating chats

* even simpler

* always use updateChats

* make chats readonly from outside of model
This commit is contained in:
Evgeny
2024-08-20 09:29:52 +01:00
committed by GitHub
parent 885aa9cfa5
commit 70991debfd
7 changed files with 20 additions and 35 deletions
+3 -6
View File
@@ -1591,8 +1591,7 @@ func getUserChatData() throws {
m.userAddress = try apiGetUserAddress()
m.chatItemTTL = try getChatItemTTL()
let chats = try apiGetChats()
m.chats = chats.map { Chat.init($0) }
m.popChatCollector.clear()
m.updateChats(chats)
}
private func getUserChatDataAsync() async throws {
@@ -1604,14 +1603,12 @@ private func getUserChatDataAsync() async throws {
await MainActor.run {
m.userAddress = userAddress
m.chatItemTTL = chatItemTTL
m.chats = chats.map { Chat.init($0) }
m.popChatCollector.clear()
m.updateChats(chats)
}
} else {
await MainActor.run {
m.userAddress = nil
m.chats = []
m.popChatCollector.clear()
m.updateChats([])
}
}
}