ios: stopped state for DB management, suspend quicker/instantly on app termination (#783)

* ios: stopped state for DB management, suspend quicker/instantly on app termination

* update terminateChat
This commit is contained in:
Evgeny Poberezkin
2022-07-06 14:07:27 +01:00
committed by GitHub
parent 6b89eb872b
commit 95f518a582
4 changed files with 37 additions and 6 deletions

View File

@@ -223,6 +223,7 @@ struct DatabaseView: View {
try await apiStopChat()
ChatReceiver.shared.stop()
await MainActor.run { m.chatRunning = false }
appStateGroupDefault.set(.stopped)
} catch let error {
await MainActor.run {
runChat = true
@@ -307,6 +308,7 @@ struct DatabaseView: View {
do {
try initializeChat(start: true)
m.chatDbChanged = false
appStateGroupDefault.set(.active)
} catch let error {
fatalError("Error starting chat \(responseError(error))")
}
@@ -318,6 +320,7 @@ struct DatabaseView: View {
m.chatRunning = true
ChatReceiver.shared.start()
chatLastStartGroupDefault.set(Date.now)
appStateGroupDefault.set(.active)
} catch let error {
runChat = false
alert = .error(title: "Error starting chat", error: responseError(error))