Skip to content

Commit

Permalink
fix(updates): do not show toast on config change
Browse files Browse the repository at this point in the history
  • Loading branch information
aliernfrog committed Sep 14, 2024
1 parent 947efe1 commit e6ccaaa
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
Expand Down Expand Up @@ -45,6 +49,7 @@ class MainActivity : AppCompatActivity() {
val view = LocalView.current
val scope = rememberCoroutineScope()
val useDarkTheme = shouldUseDarkTheme(mainViewModel.prefs.theme.value)
var isAppInitialized by rememberSaveable { mutableStateOf(false) }

@Composable
fun AppTheme(content: @Composable () -> Unit) {
Expand All @@ -67,13 +72,14 @@ class MainActivity : AppCompatActivity() {
LaunchedEffect(Unit) {
mainViewModel.scope = scope
mainViewModel.topToastState.setComposeView(view)
mainViewModel.topToastState.setAppTheme { AppTheme(it) }
if (isAppInitialized) return@LaunchedEffect

mainViewModel.topToastState.setAppTheme { AppTheme(it) }
if (mainViewModel.prefs.autoCheckUpdates.value) mainViewModel.checkUpdates()

this@MainActivity.intent?.let {
mainViewModel.handleIntent(it, context = context)
}
isAppInitialized = true
}
}

Expand Down

0 comments on commit e6ccaaa

Please sign in to comment.