@@ -64,8 +64,10 @@ import net.mullvad.mullvadvpn.compose.cell.SwitchComposeSubtitleCell
64
64
import net.mullvad.mullvadvpn.compose.cell.ThreeDotCell
65
65
import net.mullvad.mullvadvpn.compose.communication.Created
66
66
import net.mullvad.mullvadvpn.compose.communication.CustomListAction
67
+ import net.mullvad.mullvadvpn.compose.communication.CustomListActionResult
67
68
import net.mullvad.mullvadvpn.compose.communication.CustomListSuccess
68
69
import net.mullvad.mullvadvpn.compose.communication.Deleted
70
+ import net.mullvad.mullvadvpn.compose.communication.GenericError
69
71
import net.mullvad.mullvadvpn.compose.communication.LocationsChanged
70
72
import net.mullvad.mullvadvpn.compose.communication.Renamed
71
73
import net.mullvad.mullvadvpn.compose.component.LocationsEmptyText
@@ -134,9 +136,9 @@ fun SelectLocation(
134
136
deleteCustomListDialogResultRecipient : ResultRecipient <DeleteCustomListDestination , Deleted >,
135
137
updateCustomListResultRecipient :
136
138
ResultRecipient <CustomListLocationsDestination , LocationsChanged >,
137
- locationSheetResultRecipient : ResultRecipient <LocationSheetDestination , CustomListSuccess >,
139
+ locationSheetResultRecipient : ResultRecipient <LocationSheetDestination , CustomListActionResult >,
138
140
customListEntryResultRecipient :
139
- ResultRecipient <CustomListEntrySheetDestination , LocationsChanged >
141
+ ResultRecipient <CustomListEntrySheetDestination , CustomListActionResult >
140
142
) {
141
143
val vm = koinViewModel<SelectLocationViewModel >()
142
144
val state = vm.uiState.collectAsStateWithLifecycle().value
@@ -519,7 +521,7 @@ private fun CustomListSuccess.message(context: Context): String =
519
521
}
520
522
521
523
@Composable
522
- private fun <D : DestinationSpec , R : CustomListSuccess > ResultRecipient <D , R >
524
+ private fun <D : DestinationSpec , R : CustomListActionResult > ResultRecipient <D , R >
523
525
.OnCustomListNavResult (
524
526
snackbarHostState : SnackbarHostState ,
525
527
performAction : (action: CustomListAction ) -> Unit
@@ -533,12 +535,24 @@ private fun <D : DestinationSpec, R : CustomListSuccess> ResultRecipient<D, R>
533
535
}
534
536
is NavResult .Value -> {
535
537
// Handle result
536
- scope.launch {
537
- snackbarHostState.showResultSnackbar(
538
- context = context,
539
- result = result.value,
540
- onUndo = performAction
541
- )
538
+ val customListActionResult = result.value
539
+ when (customListActionResult) {
540
+ is GenericError -> {
541
+ scope.launch {
542
+ snackbarHostState.showSnackbarImmediately(
543
+ message = context.getString(R .string.error_occurred),
544
+ duration = SnackbarDuration .Short
545
+ )
546
+ }
547
+ }
548
+ is CustomListSuccess ->
549
+ scope.launch {
550
+ snackbarHostState.showResultSnackbar(
551
+ context = context,
552
+ result = customListActionResult,
553
+ onUndo = performAction
554
+ )
555
+ }
542
556
}
543
557
}
544
558
}
0 commit comments