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.
This commit is contained in:
daplugg23
2026-02-05 18:04:29 -06:00
parent 0df57f7724
commit dac42ea042

View File

@@ -275,19 +275,28 @@ class BetterLocationRoot : Routes.Route() {
)
}
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 }) {
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()
}
}
}
@@ -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 }
}
}