Skip to content

Commit

Permalink
Fix crash when removing the NoDaemonScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Jul 29, 2024
1 parent 7b30164 commit fbae2f7
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import com.ramcosta.composedestinations.generated.destinations.ChangelogDestinat
import com.ramcosta.composedestinations.generated.destinations.ConnectDestination
import com.ramcosta.composedestinations.generated.destinations.NoDaemonDestination
import com.ramcosta.composedestinations.generated.destinations.OutOfTimeDestination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.ramcosta.composedestinations.rememberNavHostEngine
import com.ramcosta.composedestinations.utils.destination
import com.ramcosta.composedestinations.utils.rememberDestinationsNavigator
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import net.mullvad.mullvadvpn.compose.util.LaunchedEffectCollect
Expand All @@ -35,6 +37,7 @@ private val changeLogDestinations = listOf(ConnectDestination, OutOfTimeDestinat
fun MullvadApp() {
val engine = rememberNavHostEngine()
val navController: NavHostController = engine.rememberNavController()
val navigator: DestinationsNavigator = navController.rememberDestinationsNavigator()

val serviceVm = koinViewModel<NoDaemonViewModel>()
val permissionVm = koinViewModel<VpnPermissionViewModel>()
Expand All @@ -55,8 +58,8 @@ fun MullvadApp() {
LaunchedEffectCollect(serviceVm.uiSideEffect) {
when (it) {
DaemonScreenEvent.Show ->
navController.navigate(NoDaemonDestination) { launchSingleTop = true }
DaemonScreenEvent.Remove -> navController.popBackStack(NoDaemonDestination, true)
navigator.navigate(NoDaemonDestination) { launchSingleTop = true }
DaemonScreenEvent.Remove -> navigator.popBackStack(NoDaemonDestination, true)
}
}

Expand All @@ -69,7 +72,7 @@ fun MullvadApp() {
.map { it.destination() }
.first { it in changeLogDestinations }

navController.navigate(ChangelogDestination(it).route)
navigator.navigate(ChangelogDestination(it))
}

// Ask for VPN Permission
Expand Down

0 comments on commit fbae2f7

Please sign in to comment.