ios: update chats after setting chat item TTL (#1179)

This commit is contained in:
JRoberts
2022-10-07 10:55:54 +04:00
committed by GitHub
parent 6d06dda645
commit 83c1340830

View File

@@ -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())