android, desktop: show alert when import database is failed or succeeded (#5402)

This commit is contained in:
Stanislav Dmitrenko
2024-12-22 16:19:05 +00:00
committed by GitHub
parent 6ff5e7cf23
commit 3fead10ea2
2 changed files with 5 additions and 4 deletions
@@ -60,8 +60,7 @@ fun DatabaseView() {
if (to != null) {
importArchiveAlert {
stopChatRunBlockStartChat(stopped, chatLastStart, progressIndicator) {
importArchive(to, appFilesCountAndSize, progressIndicator)
true
importArchive(to, appFilesCountAndSize, progressIndicator, false)
}
}
}
@@ -645,6 +644,7 @@ suspend fun importArchive(
importedArchiveURI: URI,
appFilesCountAndSize: MutableState<Pair<Int, Long>>,
progressIndicator: MutableState<Boolean>,
migration: Boolean
): Boolean {
val m = chatModel
progressIndicator.value = true
@@ -666,12 +666,13 @@ suspend fun importArchive(
if (chatModel.localUserCreated.value == false) {
chatModel.chatRunning.value = false
}
return true
} else {
operationEnded(m, progressIndicator) {
showArchiveImportedWithErrorsAlert(archiveErrors)
}
return migration
}
return true
} catch (e: Error) {
operationEnded(m, progressIndicator) {
AlertManager.shared.showAlertMsg(generalGetString(MR.strings.error_importing_database), e.toString())
@@ -239,7 +239,7 @@ private fun ArchiveImportView(progressIndicator: MutableState<Boolean>, close: (
val importArchiveLauncher = rememberFileChooserLauncher(true) { to: URI? ->
if (to != null) {
withLongRunningApi {
val success = importArchive(to, mutableStateOf(0 to 0), progressIndicator)
val success = importArchive(to, mutableStateOf(0 to 0), progressIndicator, true)
if (success) {
startChat(
chatModel,