From dac42ea042e6eaf2ae0638e28393a3600292dd1b Mon Sep 17 00:00:00 2001 From: daplugg23 Date: Thu, 5 Feb 2026 18:04:29 -0600 Subject: [PATCH] fix(location): force UI update on setting change Use mutable state for locationSearchProvider and googleMapsApiKey display values in BetterLocationRoot. Update these state variables immediately when dialogs are dismissed/saved to ensure the UI reflects changes without reopening the screen. - Introduce currentProvider/currentApiKey state variables. - Refresh state in onDismissRequest/callbacks. --- .../pages/location/BetterLocationRoot.kt | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/location/BetterLocationRoot.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/location/BetterLocationRoot.kt index 8e988b59..c89c6338 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/location/BetterLocationRoot.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/location/BetterLocationRoot.kt @@ -275,22 +275,31 @@ class BetterLocationRoot : Routes.Route() { ) } - if (showProviderDialog) { - me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = { - showProviderDialog = false - context.config.writeConfig() - }) { - alertDialogs.UniqueSelectionDialog(providerProperty) - } - } - if (showApiKeyDialog) { - me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = { showApiKeyDialog = false }) { - alertDialogs.KeyboardInputDialog(apiKeyProperty) { - showApiKeyDialog = false - context.config.writeConfig() - } - } - } + var currentProvider by remember { mutableStateOf(context.config.root.global.betterLocation.locationSearchProvider.get()) } + var currentApiKey by remember { mutableStateOf(context.config.root.global.betterLocation.googleMapsApiKey.get()) } + + if (showProviderDialog) { + me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = { + showProviderDialog = false + context.config.writeConfig() + currentProvider = context.config.root.global.betterLocation.locationSearchProvider.get() + }) { + alertDialogs.UniqueSelectionDialog(providerProperty) + } + } + if (showApiKeyDialog) { + me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = { + showApiKeyDialog = false + context.config.writeConfig() + currentApiKey = context.config.root.global.betterLocation.googleMapsApiKey.get() + }) { + alertDialogs.KeyboardInputDialog(apiKeyProperty) { + showApiKeyDialog = false + context.config.writeConfig() + currentApiKey = context.config.root.global.betterLocation.googleMapsApiKey.get() + } + } + } Column( modifier = Modifier @@ -448,7 +457,6 @@ class BetterLocationRoot : Routes.Route() { ConfigSelector(text, if (value.isNotEmpty()) "********" else translation["options.empty"], onClick) } - val currentProvider = context.config.root.global.betterLocation.locationSearchProvider.get() ConfigSelector( text = translation["location_search_provider_title"], value = translation["option_$currentProvider"] @@ -457,7 +465,7 @@ class BetterLocationRoot : Routes.Route() { if (currentProvider == "google_maps") { ConfigInput( text = translation["google_maps_api_key_title"], - value = context.config.root.global.betterLocation.googleMapsApiKey.get() + value = currentApiKey ) { showApiKeyDialog = true } } }