From af54e777dc9079bdf7d9e69c83df3664a3409732 Mon Sep 17 00:00:00 2001 From: Ray <154766448+damontecres@users.noreply.github.com> Date: Mon, 22 Dec 2025 15:28:21 -0500 Subject: [PATCH] Fix settings changes requiring an app restart (#539) ## Description - Ensures settings changes take effect immediately instead of requiring an app restart - Add conditional & catch when checking for app updates ### Related issues Fixes issues introduced in #538 --- .../damontecres/wholphin/MainActivity.kt | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt b/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt index 22e41a49..41d24b3c 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/MainActivity.kt @@ -13,6 +13,7 @@ import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.RectangleShape @@ -189,18 +190,32 @@ class MainActivity : AppCompatActivity() { is SetupDestination.AppContent -> { val current = key.current - val preferences = - UserPreferences( - appPreferences, - current.userDto.configuration - ?: DefaultUserConfiguration, - ) ProvideLocalClock { - LaunchedEffect(Unit) { - updateChecker.maybeShowUpdateToast( - appPreferences.updateUrl, - ) + if (UpdateChecker.ACTIVE && appPreferences.autoCheckForUpdates) { + LaunchedEffect(Unit) { + try { + updateChecker.maybeShowUpdateToast( + appPreferences.updateUrl, + ) + } catch (ex: Exception) { + Timber.w( + ex, + "Exception during update check", + ) + } + } } + val appPreferences by userPreferencesDataStore.data.collectAsState( + appPreferences, + ) + val preferences = + remember(appPreferences, current) { + UserPreferences( + appPreferences, + current.userDto.configuration + ?: DefaultUserConfiguration, + ) + } ApplicationContent( user = current.user, server = current.server,