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 11, 2024
1 parent 84d328d commit f1c136d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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 @@ -48,6 +52,7 @@ class MainActivity : AppCompatActivity() {
val view = LocalView.current
val scope = rememberCoroutineScope()
val darkTheme = isDarkThemeEnabled(mainViewModel.prefs.theme.value)
var isAppInitialized by rememberSaveable { mutableStateOf(false) }

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

Expand All @@ -82,6 +88,8 @@ class MainActivity : AppCompatActivity() {
this@MainActivity.intent?.let {
mainViewModel.handleIntent(it, context = context)
}

isAppInitialized = true
}
}

Expand Down

0 comments on commit f1c136d

Please sign in to comment.