Prevent un-necessary config save and restart alert in settings screen
This commit is contained in:
@ -152,6 +152,8 @@ private fun SettingsScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(null) {
|
LaunchedEffect(null) {
|
||||||
|
save = false
|
||||||
|
restart = false
|
||||||
settingsViewModel.loadSettings(ctx)
|
settingsViewModel.loadSettings(ctx)
|
||||||
areSettingsLoaded = true
|
areSettingsLoaded = true
|
||||||
}
|
}
|
||||||
@ -191,7 +193,7 @@ private fun SettingsScreen(
|
|||||||
}
|
}
|
||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
|
|
||||||
if (showRestartDialog.value) {
|
if (showRestartDialog.value)
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showRestartDialog,
|
showDialog = showRestartDialog,
|
||||||
title = stringResource(R.string.restart_request),
|
title = stringResource(R.string.restart_request),
|
||||||
@ -201,7 +203,6 @@ private fun SettingsScreen(
|
|||||||
lastButtonText = stringResource(R.string.restart),
|
lastButtonText = stringResource(R.string.restart),
|
||||||
onLastClicked = { onRestartApp() },
|
onLastClicked = { onRestartApp() },
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
if (areSettingsLoaded && activity != null)
|
if (areSettingsLoaded && activity != null)
|
||||||
SettingsContent(settingsViewModel, contentPadding, navController, activity, onRestartApp)
|
SettingsContent(settingsViewModel, contentPadding, navController, activity, onRestartApp)
|
||||||
@ -264,7 +265,7 @@ private fun SettingsContent(
|
|||||||
val okButtonText = stringResource(R.string.ok)
|
val okButtonText = stringResource(R.string.ok)
|
||||||
val cancelButtonText = stringResource(R.string.cancel)
|
val cancelButtonText = stringResource(R.string.cancel)
|
||||||
|
|
||||||
if (showAlert.value) {
|
if (showAlert.value)
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showAlert,
|
showDialog = showAlert,
|
||||||
title = alertTitle.value,
|
title = alertTitle.value,
|
||||||
@ -272,7 +273,6 @@ private fun SettingsContent(
|
|||||||
firstButtonText = "",
|
firstButtonText = "",
|
||||||
lastButtonText = okButtonText,
|
lastButtonText = okButtonText,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
if (showDialog.value)
|
if (showDialog.value)
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
|
|||||||
Reference in New Issue
Block a user