android, desktop: start/stop chat toggle refactoring (#5261)

* android, desktop: start/stop chat toggle refactoring

* changes

* translations

* better

* better

* do not start chat after export, always show run toggle (#5283)

* update heading

---------

Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
Stanislav Dmitrenko
2024-11-30 16:33:38 +00:00
committed by GitHub
co-authored by Evgeny Poberezkin
parent 961bdbfc59
commit 4738286f4e
43 changed files with 236 additions and 446 deletions
@@ -3,6 +3,7 @@ package chat.simplex.common.platform
import chat.simplex.common.model.*
import chat.simplex.common.simplexWindowState
import chat.simplex.common.views.call.RcvCallInvitation
import chat.simplex.common.views.database.deleteOldChatArchive
import chat.simplex.common.views.helpers.*
import java.util.*
import chat.simplex.res.MR
@@ -30,6 +31,7 @@ fun initApp() {
override fun showMessage(title: String, text: String) = chat.simplex.common.model.NtfManager.showMessage(title, text)
}
applyAppLocale()
deleteOldChatArchive()
if (DatabaseUtils.ksSelfDestructPassword.get() == null) {
initChatControllerOnStart()
}
@@ -9,14 +9,14 @@ import kotlinx.datetime.Instant
actual fun restartChatOrApp() {
if (chatModel.chatRunning.value == false) {
chatModel.chatDbChanged.value = true
startChat(chatModel, mutableStateOf(Instant.DISTANT_PAST), chatModel.chatDbChanged)
startChat(chatModel, mutableStateOf(Instant.DISTANT_PAST), chatModel.chatDbChanged, mutableStateOf(false))
} else {
authStopChat(chatModel) {
withBGApi {
// adding delay in order to prevent locked database by previous initialization
delay(1000)
chatModel.chatDbChanged.value = true
startChat(chatModel, mutableStateOf(Instant.DISTANT_PAST), chatModel.chatDbChanged)
startChat(chatModel, mutableStateOf(Instant.DISTANT_PAST), chatModel.chatDbChanged, mutableStateOf(false))
}
}
}