ios: fix messages reseting position, when app is brought from background to foreground (#4686)

* ios: fix messages reseting position, when app is brought back to foreground

* minor
This commit is contained in:
Arturs Krumins
2024-08-14 22:14:40 +03:00
committed by GitHub
parent f6ef57534f
commit 46a60d979b
2 changed files with 5 additions and 3 deletions

View File

@@ -332,13 +332,15 @@ func apiGetChatItems(type: ChatType, id: Int64, pagination: ChatPagination, sear
throw r
}
func loadChat(chat: Chat, search: String = "") async {
func loadChat(chat: Chat, search: String = "", clearItems: Bool = true) async {
do {
let cInfo = chat.chatInfo
let m = ChatModel.shared
let im = ItemsModel.shared
m.chatItemStatuses = [:]
await MainActor.run { im.reversedChatItems = [] }
if clearItems {
await MainActor.run { im.reversedChatItems = [] }
}
let chat = try await apiGetChat(type: cInfo.chatType, id: cInfo.apiId, search: search)
await MainActor.run {
im.reversedChatItems = chat.chatItems.reversed()

View File

@@ -136,7 +136,7 @@ struct SimpleXApp: App {
chatModel.updateChats(with: chats)
if let id = chatModel.chatId,
let chat = chatModel.getChat(id) {
Task { await loadChat(chat: chat) }
Task { await loadChat(chat: chat, clearItems: false) }
}
if let ncr = chatModel.ntfContactRequest {
chatModel.ntfContactRequest = nil