From 83c1340830d78f307c50f25426dfe4b044800854 Mon Sep 17 00:00:00 2001 From: JRoberts <8711996+jr-simplex@users.noreply.github.com> Date: Fri, 7 Oct 2022 10:55:54 +0400 Subject: [PATCH] ios: update chats after setting chat item TTL (#1179) --- .../Shared/Views/Database/DatabaseView.swift | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/ios/Shared/Views/Database/DatabaseView.swift b/apps/ios/Shared/Views/Database/DatabaseView.swift index edb6d2b70..772adc4e0 100644 --- a/apps/ios/Shared/Views/Database/DatabaseView.swift +++ b/apps/ios/Shared/Views/Database/DatabaseView.swift @@ -430,20 +430,29 @@ struct DatabaseView: View { await MainActor.run { m.chatItemTTL = ttl currentChatItemTTL = ttl - progressIndicator = false - appFilesCountAndSize = directoryFileCountAndSize(getAppFilesDirectory()) + afterSetCiTTL() } } catch { await MainActor.run { alert = .error(title: "Error changing setting", error: responseError(error)) chatItemTTL = currentChatItemTTL - progressIndicator = false - appFilesCountAndSize = directoryFileCountAndSize(getAppFilesDirectory()) + afterSetCiTTL() } } } } + private func afterSetCiTTL() { + progressIndicator = false + appFilesCountAndSize = directoryFileCountAndSize(getAppFilesDirectory()) + do { + let chats = try apiGetChats() + m.updateChats(with: chats) + } catch let error { + logger.error("apiGetChats: cannot update chats \(responseError(error))") + } + } + private func deleteFiles() { deleteAppFiles() appFilesCountAndSize = directoryFileCountAndSize(getAppFilesDirectory())