Skip to content

Commit

Permalink
Do not exit the app if a screen fails internally, instead just show a…
Browse files Browse the repository at this point in the history
…n error message
  • Loading branch information
AChep committed Jan 22, 2024
1 parent 44ac23f commit 021b2a8
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import com.artemchep.keyguard.common.usecase.GetScreenState
import com.artemchep.keyguard.common.usecase.PutScreenState
import com.artemchep.keyguard.common.usecase.ShowMessage
import com.artemchep.keyguard.common.usecase.WindowCoroutineScope
import com.artemchep.keyguard.common.usecase.impl.WindowCoroutineScopeImpl
import com.artemchep.keyguard.feature.navigation.NavigationController
import com.artemchep.keyguard.feature.navigation.NavigationEntry
import com.artemchep.keyguard.platform.LeBundle
import com.artemchep.keyguard.platform.LeContext
import com.artemchep.keyguard.platform.leBundleOf
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.plus
import kotlinx.serialization.json.Json

Expand Down Expand Up @@ -47,10 +49,14 @@ class FlowHolderViewModel(
init: RememberStateFlowScope.() -> T,
): T = synchronized(this) {
store.getOrPut(key) {
val job = Job()
val scope = RememberStateFlowScopeImpl(
val vmCoroutineScopeJob = SupervisorJob()
val vmCoroutineScope = WindowCoroutineScopeImpl(
scope = scope + vmCoroutineScopeJob + Dispatchers.Default,
showMessage = showMessage,
)
val vmScope = RememberStateFlowScopeImpl(
key = key,
scope = scope + job + Dispatchers.Default,
scope = vmCoroutineScope,
navigationController = c,
backPressInterceptorHost = navigationEntry,
showMessage = showMessage,
Expand All @@ -64,11 +70,11 @@ class FlowHolderViewModel(
colorSchemeState = colorSchemeState,
context = context,
)
val value = init(scope)
val value = init(vmScope)
Some(
Entry(
scope = scope,
job = job,
scope = vmScope,
job = vmCoroutineScopeJob,
value = value,
),
)
Expand Down

0 comments on commit 021b2a8

Please sign in to comment.