From 3c4c4a4001884dc875f0ecd5e0d0408437f75c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 5 Oct 2023 14:00:21 +0200 Subject: [PATCH] Use `eventValue` for `isOrWasThankYouInstalled` --- .../flashlight/extensions/Activity.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/extensions/Activity.kt index 2c8d65e..c96d708 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/extensions/Activity.kt @@ -14,6 +14,7 @@ import com.simplemobiletools.commons.activities.AboutActivity import com.simplemobiletools.commons.activities.CustomizationActivity import com.simplemobiletools.commons.compose.alert_dialog.rememberAlertDialogState import com.simplemobiletools.commons.compose.extensions.getActivity +import com.simplemobiletools.commons.compose.extensions.onEventValue import com.simplemobiletools.commons.dialogs.FeatureLockedAlertDialog import com.simplemobiletools.commons.extensions.hideKeyboard import com.simplemobiletools.commons.extensions.isOrWasThankYouInstalled @@ -92,21 +93,24 @@ fun CheckFeatureLocked( skipCheck: Boolean ) { val context = LocalContext.current.getActivity() + val isOrWasThankYouInstalled = onEventValue { + context.isOrWasThankYouInstalled() + } val featureLockedAlertDialogState = rememberAlertDialogState().apply { DialogMember { FeatureLockedAlertDialog( alertDialogState = this, ) { - if (!context.isOrWasThankYouInstalled()) { + if (!isOrWasThankYouInstalled) { context.finish() } } } } - LaunchedEffect(context.isOrWasThankYouInstalled()) { - if (!skipCheck && !context.isOrWasThankYouInstalled()) { + LaunchedEffect(isOrWasThankYouInstalled) { + if (!skipCheck && !isOrWasThankYouInstalled) { featureLockedAlertDialogState.show() - } else if (context.isOrWasThankYouInstalled()) { + } else if (isOrWasThankYouInstalled) { featureLockedAlertDialogState.hide() } }