From 2bf544498cbe7f1df5ac5e84bd8f86167f03c3ad Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Sun, 11 Oct 2026 08:09:07 +0200 Subject: [PATCH] fix: Fix outdated settings on navigation screens Passed the settings state object instead of a plain value to the main application component. This ensured screens kept displaying the current settings rather than the stale values from when they were initially opened. Signed-off-by: Chmouel Boudjnah --- .../main/kotlin/com/chmouel/liseur/MainActivity.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/chmouel/liseur/MainActivity.kt b/app/src/main/kotlin/com/chmouel/liseur/MainActivity.kt index 5c701151..ca90cdc9 100644 --- a/app/src/main/kotlin/com/chmouel/liseur/MainActivity.kt +++ b/app/src/main/kotlin/com/chmouel/liseur/MainActivity.kt @@ -26,6 +26,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableLongStateOf import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.State import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable @@ -155,8 +156,9 @@ class MainActivity : ComponentActivity() { if (LaunchRequests.shared.pending.value != null) deciding = false setContent { - val settings by container.appSettings.settings + val settingsState = container.appSettings.settings .collectAsState(initial = AppSettings()) + val settings by settingsState val appIsDark = settings.themeMode.isDark() // enableEdgeToEdge() above picked the icon colour from the // configuration this activity was created in and will not be @@ -175,7 +177,7 @@ class MainActivity : ComponentActivity() { ) { val resolution by launchModel.ready.collectAsStateWithLifecycle() LiseurApp( - settings, + settingsState, launch = resolution, onLaunchHandled = launchModel::handled, ) @@ -256,10 +258,14 @@ private const val SPONSOR_URL = "https://github.com/sponsors/chmouel" @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable private fun LiseurApp( - settings: AppSettings, + settingsState: State, launch: LaunchResolution? = null, onLaunchHandled: (LaunchRequest) -> Unit = {}, ) { + // Read through the State, not passed in as a value: NavDisplay keeps + // each entry's content, so a plain value would leave every screen + // showing the settings as they were when it opened. + val settings by settingsState // The screens open, library at the bottom. Back closes the top one, so // the server screen returns to whichever screen opened it, and book // statistics to the shelf, the series or the overall statistics.