Skip to content

Commit

Permalink
fixed a bug with crash after login
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonidius20 committed Mar 1, 2024
1 parent 63b9bc3 commit 6284c24
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/src/main/java/ua/leonidius/beatinspector/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.browser.customtabs.CustomTabsIntent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.core.net.toUri
Expand Down Expand Up @@ -72,13 +73,15 @@ class MainActivity : ComponentActivity() {
NavHost(navController = navController, startDestination = startDestination) {
composable("login") {
if (viewModel.uiState is AuthStatusViewModel.UiState.SuccessfulLogin) {
// todo: performance optimization?
// LaunchedEffect(key1 = null, {})
navController.navigate("search") {
popUpTo("login") {
inclusive = true

LaunchedEffect(key1 = null) {
navController.navigate("playlists") {
popUpTo("login") {
inclusive = true
}
}
}

} else {
LoginScreen(viewModel = viewModel, onLoginButtonPressed = {
// for some reason, UI is only recomposed when we use the viewmodel from the argument
Expand Down

0 comments on commit 6284c24

Please sign in to comment.