From 741ef3af05edd385b5d2df895c31d36c43537306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Fri, 20 Oct 2023 11:24:01 +0200 Subject: [PATCH] Clean up hide dialog --- .../ui/fragment/VpnSettingsFragment.kt | 2 +- .../viewmodel/VpnSettingsViewModel.kt | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/VpnSettingsFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/VpnSettingsFragment.kt index e3ed6c469dbd..49d43e6b2770 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/VpnSettingsFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/VpnSettingsFragment.kt @@ -43,7 +43,7 @@ class VpnSettingsFragment : BaseFragment() { onDnsInputChange = vm::onDnsInputChange, onSaveDnsClick = vm::onSaveDnsClick, onRemoveDnsClick = vm::onRemoveDnsClick, - onCancelDnsDialogClick = vm::onCancelDialogClick, + onCancelDnsDialogClick = vm::onCancelDns, onLocalNetworkSharingInfoClick = vm::onLocalNetworkSharingInfoClick, onContentsBlockersInfoClick = vm::onContentsBlockerInfoClick, onCustomDnsInfoClick = vm::onCustomDnsInfoClick, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModel.kt index 8a66818896a2..0827c81e9928 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModel.kt @@ -77,14 +77,14 @@ class VpnSettingsViewModel( isLocalNetworkSharingEnabled = settings?.allowLan ?: false, isCustomDnsEnabled = settings?.isCustomDnsEnabled() ?: false, customDnsList = settings?.addresses()?.asStringAddressList() ?: listOf(), - contentBlockersOptions = - settings?.contentBlockersSettings() ?: DefaultDnsOptions(), + contentBlockersOptions = settings?.contentBlockersSettings() + ?: DefaultDnsOptions(), isAllowLanEnabled = settings?.allowLan ?: false, - selectedObfuscation = - settings?.selectedObfuscationSettings() ?: SelectedObfuscation.Off, + selectedObfuscation = settings?.selectedObfuscationSettings() + ?: SelectedObfuscation.Off, dialogState = dialogState, - quantumResistant = - settings?.quantumResistant() ?: QuantumResistantState.Off, + quantumResistant = settings?.quantumResistant() + ?: QuantumResistantState.Off, selectedWireguardPort = settings?.getWireguardPort() ?: Constraint.Any(), availablePortRanges = portRanges ) @@ -238,7 +238,7 @@ class VpnSettingsViewModel( contentBlockersOptions = vmState.value.contentBlockersOptions ) - dialogState.update { null } + hideDialog() } fun onToggleAutoConnect(isEnabled: Boolean) { @@ -376,13 +376,17 @@ class VpnSettingsViewModel( } private fun hideDialog() { + dialogState.update { null } + } + + fun onCancelDns() { if ( vmState.value.dialogState is VpnSettingsDialogState.DnsDialog && vmState.value.customDnsList.isEmpty() ) { onToggleDnsClick(false) } - dialogState.update { null } + hideDialog() } private fun String.isDuplicateDns(stagedIndex: Int? = null): Boolean {