fix force update stuff
This commit is contained in:
+7
-3
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user