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