From d06292c0718b29cd80aa1c4894f3c02b6fb230ae Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Sun, 7 Jan 2024 23:07:32 +0200 Subject: [PATCH] fix: Fix AWT thread crash that happens because the compose state gets updated from another thread --- .../feature/navigation/state/RememberStateFlowScopeImpl.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/navigation/state/RememberStateFlowScopeImpl.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/navigation/state/RememberStateFlowScopeImpl.kt index 010c07f..96009f7 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/navigation/state/RememberStateFlowScopeImpl.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/navigation/state/RememberStateFlowScopeImpl.kt @@ -23,6 +23,7 @@ import com.artemchep.keyguard.platform.get import com.artemchep.keyguard.platform.leBundleOf import dev.icerock.moko.resources.StringResource import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.Flow @@ -63,7 +64,7 @@ class RememberStateFlowScopeImpl( sink: MutableStateFlow, ) { private val collectScope by lazy { - scope + Job() + scope + Dispatchers.Main + Job() } val mutableState by lazy {