From 3bddb5538528c19388e364d21e6a6c16487af759 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sat, 12 Oct 2024 05:02:56 +0600 Subject: [PATCH] Tweak Preference.collectAsState Co-authored-by: p --- .../java/tachiyomi/presentation/core/util/Preference.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/util/Preference.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/util/Preference.kt index 4b7a5018a..492ae688e 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/util/Preference.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/util/Preference.kt @@ -4,10 +4,12 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.State import androidx.compose.runtime.collectAsState import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import kotlinx.coroutines.CoroutineScope import tachiyomi.core.common.preference.Preference @Composable -fun Preference.collectAsState(): State { - val flow = remember(this) { changes() } - return flow.collectAsState(initial = get()) +fun Preference.collectAsState(scope: CoroutineScope = rememberCoroutineScope()): State { + val flow = remember(this) { stateIn(scope) } + return flow.collectAsState() }