From 702e405bb4d1845378100b5ab0d9d2a179dc22d3 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Tue, 21 Jan 2025 19:20:04 -0800 Subject: [PATCH] change after merge --- apps/ios/Shared/Model/SimpleXAPI.swift | 1 - apps/ios/Shared/Views/Chat/ChatInfoView.swift | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/ios/Shared/Model/SimpleXAPI.swift b/apps/ios/Shared/Model/SimpleXAPI.swift index ea7301e756..83cedd88cf 100644 --- a/apps/ios/Shared/Model/SimpleXAPI.swift +++ b/apps/ios/Shared/Model/SimpleXAPI.swift @@ -342,7 +342,6 @@ func apiGetChatItems(type: ChatType, id: Int64, pagination: ChatPagination, sear func loadChat(type: ChatType, id: Int64, search: String = "", clearItems: Bool = true) async { // do { - let cInfo = chat.chatInfo let m = ChatModel.shared let im = ItemsModel.shared m.chatItemStatuses = [:] diff --git a/apps/ios/Shared/Views/Chat/ChatInfoView.swift b/apps/ios/Shared/Views/Chat/ChatInfoView.swift index 7a5003c94d..afee2b6b81 100644 --- a/apps/ios/Shared/Views/Chat/ChatInfoView.swift +++ b/apps/ios/Shared/Views/Chat/ChatInfoView.swift @@ -682,17 +682,23 @@ struct ChatTTLOption: View { ) { progressIndicator = true Task { + let m = ChatModel.shared do { try await setChatTTL(chatType: chat.chatInfo.chatType, id: chat.chatInfo.apiId, ttl) - await loadChat(chat: chat, clearItems: true, replaceChat: true) + await loadChat(type: chat.chatInfo.chatType, id: chat.chatInfo.apiId, clearItems: true) await MainActor.run { progressIndicator = false currentChatItemTTL = chatItemTTL + if ItemsModel.shared.reversedChatItems.isEmpty && m.chatId == chat.id, + let chat = m.getChat(chat.id) { + chat.chatItems = [] + m.replaceChat(chat.id, chat) + } } } catch let error { logger.error("setChatTTL error \(responseError(error))") - await loadChat(chat: chat, clearItems: true, replaceChat: true) + await loadChat(type: chat.chatInfo.chatType, id: chat.chatInfo.apiId, clearItems: true) await MainActor.run { chatItemTTL = currentChatItemTTL progressIndicator = false