From 798714160c036480c8869eed7ce1e228e8e49b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Tue, 28 May 2024 14:13:53 +0200 Subject: [PATCH] Clean up launch --- .../mullvad/mullvadvpn/compose/screen/ConnectScreen.kt | 3 +-- .../mullvadvpn/compose/screen/CustomListsScreen.kt | 3 +-- .../mullvadvpn/compose/screen/SelectLocationScreen.kt | 9 +++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt index f560ddfee97c..94b5ef3b5b85 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt @@ -153,13 +153,12 @@ fun Connect( popUpTo(NavGraphs.root) { inclusive = true } } is ConnectViewModel.UiSideEffect.NoVpnPermission -> launchVpnPermission.launch(Unit) - is ConnectViewModel.UiSideEffect.ConnectError -> { + is ConnectViewModel.UiSideEffect.ConnectError -> launch { snackbarHostState.showSnackbarImmediately( message = sideEffect.toMessage(context), ) } - } } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt index 77b919a6d590..36e2ad5f4772 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt @@ -74,7 +74,7 @@ fun CustomLists( NavResult.Canceled -> { /* Do nothing */ } - is NavResult.Value -> { + is NavResult.Value -> scope.launch { snackbarHostState.showSnackbarImmediately( message = @@ -87,7 +87,6 @@ fun CustomLists( onAction = { viewModel.undoDeleteCustomList(result.value.undo) } ) } - } } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt index 6c49613543da..eb87e0f06f5f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt @@ -150,7 +150,7 @@ fun SelectLocation( LaunchedEffectCollect(vm.uiSideEffect) { when (it) { SelectLocationSideEffect.CloseScreen -> backNavigator.navigateBack(result = true, true) - is SelectLocationSideEffect.LocationAddedToCustomList -> { + is SelectLocationSideEffect.LocationAddedToCustomList -> launch { snackbarHostState.showResultSnackbar( context = context, @@ -158,8 +158,7 @@ fun SelectLocation( onUndo = vm::performAction ) } - } - is SelectLocationSideEffect.LocationRemovedFromCustomList -> { + is SelectLocationSideEffect.LocationRemovedFromCustomList -> launch { snackbarHostState.showResultSnackbar( context = context, @@ -167,15 +166,13 @@ fun SelectLocation( onUndo = vm::performAction ) } - } - SelectLocationSideEffect.GenericError -> { + SelectLocationSideEffect.GenericError -> launch { snackbarHostState.showSnackbarImmediately( message = context.getString(R.string.error_occurred), duration = SnackbarDuration.Short ) } - } } }