From db6171b160ebcaeb55c493cad38b54b7294ee204 Mon Sep 17 00:00:00 2001 From: Eugene Date: Sun, 26 Jul 2026 00:01:04 +0300 Subject: [PATCH] fix force update stuff --- .../updater/presentation/UpdateComponent.kt | 10 +++++++--- .../shadowsparky/updater/presentation/UpdateDialog.kt | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libs/updater/updater-client/src/commonMain/kotlin/ru/shadowsparky/updater/presentation/UpdateComponent.kt b/libs/updater/updater-client/src/commonMain/kotlin/ru/shadowsparky/updater/presentation/UpdateComponent.kt index 5ff391b..c4bc5a5 100644 --- a/libs/updater/updater-client/src/commonMain/kotlin/ru/shadowsparky/updater/presentation/UpdateComponent.kt +++ b/libs/updater/updater-client/src/commonMain/kotlin/ru/shadowsparky/updater/presentation/UpdateComponent.kt @@ -20,7 +20,9 @@ class UpdateComponent( private val interactor: UpdateInteractor ) : ComponentContext by componentContext { val hasSupport = interactor.hasSupport - private val exceptionHandler = CoroutineExceptionHandler { context, throwable -> + var isForceUpdate = false + private set + private val exceptionHandler = CoroutineExceptionHandler { _, throwable -> _state.value = UpdateState.Error(throwable.message ?: "$throwable", throwable) } @@ -33,7 +35,6 @@ class UpdateComponent( init { lifecycle.doOnDestroy { scope.cancel() } - lifecycle.doOnResume { val url = pendingUrl if (_state.value is UpdateState.InstallPermissionRequired && url != null) { @@ -46,7 +47,10 @@ class UpdateComponent( fun checkUpdates() { scope.launch { - interactor.checkUpdate().collect { _state.value = it } + interactor.checkUpdate().collect { + isForceUpdate = (it as? UpdateState.UpdateAvailable)?.isForceUpdate ?: false + _state.value = it + } } } diff --git a/libs/updater/updater-client/src/commonMain/kotlin/ru/shadowsparky/updater/presentation/UpdateDialog.kt b/libs/updater/updater-client/src/commonMain/kotlin/ru/shadowsparky/updater/presentation/UpdateDialog.kt index e04b648..5189bf0 100644 --- a/libs/updater/updater-client/src/commonMain/kotlin/ru/shadowsparky/updater/presentation/UpdateDialog.kt +++ b/libs/updater/updater-client/src/commonMain/kotlin/ru/shadowsparky/updater/presentation/UpdateDialog.kt @@ -39,6 +39,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.DialogProperties import com.arkivanov.decompose.extensions.compose.subscribeAsState import org.jetbrains.compose.resources.stringResource import ru.shadowsparky.ui.components.Loading @@ -51,11 +52,16 @@ fun UpdateDialog( modifier: Modifier = Modifier ) { val state by component.state.subscribeAsState() + val canDismiss = remember(state) { !component.isForceUpdate } val isVisible = remember(state) { state !is UpdateState.Idle } if (isVisible) { BasicAlertDialog( modifier = modifier, onDismissRequest = { component.reset() }, + properties = DialogProperties( + canDismiss, + canDismiss, + ), content = { Box( modifier = Modifier.clip(RoundedCornerShape(28.dp))