@@ -3,7 +3,6 @@ package net.mullvad.mullvadvpn.compose.screen
3
3
import androidx.compose.foundation.layout.fillMaxSize
4
4
import androidx.compose.runtime.Composable
5
5
import androidx.compose.runtime.DisposableEffect
6
- import androidx.compose.runtime.LaunchedEffect
7
6
import androidx.compose.ui.ExperimentalComposeUiApi
8
7
import androidx.compose.ui.Modifier
9
8
import androidx.compose.ui.semantics.semantics
@@ -14,14 +13,14 @@ import com.ramcosta.composedestinations.navigation.navigate
14
13
import com.ramcosta.composedestinations.navigation.popBackStack
15
14
import com.ramcosta.composedestinations.rememberNavHostEngine
16
15
import com.ramcosta.composedestinations.utils.destination
17
- import kotlinx.coroutines.flow.collect
18
16
import kotlinx.coroutines.flow.first
19
17
import kotlinx.coroutines.flow.map
20
18
import net.mullvad.mullvadvpn.compose.NavGraphs
21
19
import net.mullvad.mullvadvpn.compose.destinations.ChangelogDestination
22
20
import net.mullvad.mullvadvpn.compose.destinations.ConnectDestination
23
21
import net.mullvad.mullvadvpn.compose.destinations.NoDaemonScreenDestination
24
22
import net.mullvad.mullvadvpn.compose.destinations.OutOfTimeDestination
23
+ import net.mullvad.mullvadvpn.compose.util.LaunchedEffectCollect
25
24
import net.mullvad.mullvadvpn.viewmodel.ChangelogViewModel
26
25
import net.mullvad.mullvadvpn.viewmodel.DaemonScreenEvent
27
26
import net.mullvad.mullvadvpn.viewmodel.NoDaemonViewModel
@@ -50,28 +49,23 @@ fun MullvadApp() {
50
49
)
51
50
52
51
// Globally handle daemon dropped connection with NoDaemonScreen
53
- LaunchedEffect (Unit ) {
54
- serviceVm.uiSideEffect.collect {
55
- when (it) {
56
- DaemonScreenEvent .Show ->
57
- navController.navigate(NoDaemonScreenDestination ) { launchSingleTop = true }
58
- DaemonScreenEvent .Remove ->
59
- navController.popBackStack(NoDaemonScreenDestination , true )
60
- }
52
+ LaunchedEffectCollect (serviceVm.uiSideEffect) {
53
+ when (it) {
54
+ DaemonScreenEvent .Show ->
55
+ navController.navigate(NoDaemonScreenDestination ) { launchSingleTop = true }
56
+ DaemonScreenEvent .Remove -> navController.popBackStack(NoDaemonScreenDestination , true )
61
57
}
62
58
}
63
59
64
60
// Globally show the changelog
65
61
val changeLogsViewModel = koinViewModel<ChangelogViewModel >()
66
- LaunchedEffect (Unit ) {
67
- changeLogsViewModel.uiSideEffect.collect {
62
+ LaunchedEffectCollect (changeLogsViewModel.uiSideEffect) {
68
63
69
- // Wait until we are in an acceptable destination
70
- navController.currentBackStackEntryFlow
71
- .map { it.destination() }
72
- .first { it in changeLogDestinations }
64
+ // Wait until we are in an acceptable destination
65
+ navController.currentBackStackEntryFlow
66
+ .map { it.destination() }
67
+ .first { it in changeLogDestinations }
73
68
74
- navController.navigate(ChangelogDestination (it).route)
75
- }
69
+ navController.navigate(ChangelogDestination (it).route)
76
70
}
77
71
}
0 commit comments