From fd3ecd6fbe369805af01808c44d3c7ed1a9516f1 Mon Sep 17 00:00:00 2001 From: saber safavi Date: Fri, 1 Dec 2023 09:20:49 +0100 Subject: [PATCH] Remove unnecessary else block within when statement --- .../mullvad/mullvadvpn/viewmodel/VoucherDialogViewModel.kt | 7 +++---- .../service/persistence/SplitTunnelingPersistence.kt | 5 +---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VoucherDialogViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VoucherDialogViewModel.kt index 802245bb1d46..3691fc79b5a4 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VoucherDialogViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VoucherDialogViewModel.kt @@ -60,9 +60,7 @@ class VoucherDialogViewModel( when (val result = serviceConnectionManager.voucherRedeemer()?.submit(voucherCode)) { is VoucherSubmissionResult.Ok -> handleAddedTime(result.submission.timeAdded) is VoucherSubmissionResult.Error -> setError(result.error) - else -> { - vmState.update { VoucherDialogState.Default } - } + null -> vmState.update { VoucherDialogState.Default } } } } @@ -88,7 +86,8 @@ class VoucherDialogViewModel( when (error) { VoucherSubmissionError.InvalidVoucher -> R.string.invalid_voucher VoucherSubmissionError.VoucherAlreadyUsed -> R.string.voucher_already_used - else -> R.string.error_occurred + VoucherSubmissionError.RpcError, + VoucherSubmissionError.OtherError -> R.string.error_occurred } ) vmState.update { VoucherDialogState.Error(message) } diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/persistence/SplitTunnelingPersistence.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/persistence/SplitTunnelingPersistence.kt index 264304ab3f67..055c9f8777cd 100644 --- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/persistence/SplitTunnelingPersistence.kt +++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/persistence/SplitTunnelingPersistence.kt @@ -29,9 +29,6 @@ class SplitTunnelingPersistence(context: Context) { } private fun loadExcludedApps(): Set { - return when { - appListFile.exists() -> appListFile.readLines().toSet() - else -> emptySet() - } + return if (appListFile.exists()) appListFile.readLines().toSet() else emptySet() } }