withLongRunningApi (#3675)

This commit is contained in:
Stanislav Dmitrenko
2024-01-15 21:29:11 +07:00
committed by GitHub
parent bfb274b037
commit 46fe0fc671
9 changed files with 11 additions and 11 deletions
@@ -101,7 +101,7 @@ fun CIFileView(
filePath = getLoadedFilePath(file)
}
if (filePath != null) {
withBGApi {
withLongRunningApi {
saveFileLauncher.launch(file.fileName)
}
} else {
@@ -34,7 +34,7 @@ fun ChatArchiveView(m: ChatModel, title: String, archiveName: String, archiveTim
ChatArchiveLayout(
title,
archiveTime,
saveArchive = { withBGApi { saveArchiveLauncher.launch(archivePath.substringAfterLast(File.separator)) }},
saveArchive = { withLongRunningApi { saveArchiveLauncher.launch(archivePath.substringAfterLast(File.separator)) }},
deleteArchiveAlert = { deleteArchiveAlert(m, archivePath) }
)
}
@@ -240,7 +240,7 @@ fun DatabaseLayout(
SettingsActionItem(
painterResource(MR.images.ic_download),
stringResource(MR.strings.import_database),
{ withBGApi { importArchiveLauncher.launch("application/zip") } },
{ withLongRunningApi { importArchiveLauncher.launch("application/zip") } },
textColor = Color.Red,
iconColor = Color.Red,
disabled = operationsDisabled
@@ -500,7 +500,7 @@ private fun exportArchive(
saveArchiveLauncher: FileChooserLauncher
) {
progressIndicator.value = true
withBGApi {
withLongRunningApi {
try {
val archiveFile = exportChatArchive(m, chatArchiveName, chatArchiveTime, chatArchiveFile)
chatArchiveFile.value = archiveFile
@@ -39,7 +39,7 @@ fun withBGApi(action: suspend CoroutineScope.() -> Unit): Job =
CoroutineScope(singleThreadDispatcher).launch(block = { wrapWithLogging(action, it) })
}
fun withLongRunningApi(slow: Long = 120_000, deadlock: Long = 240_000, action: suspend CoroutineScope.() -> Unit): Job =
fun withLongRunningApi(slow: Long = Long.MAX_VALUE, deadlock: Long = Long.MAX_VALUE, action: suspend CoroutineScope.() -> Unit): Job =
Exception().let {
CoroutineScope(Dispatchers.Default).launch(block = { wrapWithLogging(action, it, slow = slow, deadlock = deadlock) })
}
@@ -131,7 +131,7 @@ object AppearanceScope {
SectionItemView({
val overrides = ThemeManager.currentThemeOverridesForExport(isInDarkTheme)
theme.value = yaml.encodeToString<ThemeOverrides>(overrides)
withBGApi { exportThemeLauncher.launch("simplex.theme")}
withLongRunningApi { exportThemeLauncher.launch("simplex.theme")}
}) {
Text(generalGetString(MR.strings.export_theme), color = colors.primary)
}
@@ -144,7 +144,7 @@ object AppearanceScope {
}
}
// Can not limit to YAML mime type since it's unsupported by Android
SectionItemView({ withBGApi { importThemeLauncher.launch("*/*") } }) {
SectionItemView({ withLongRunningApi { importThemeLauncher.launch("*/*") } }) {
Text(generalGetString(MR.strings.import_theme), color = colors.primary)
}
}