Skip to content

Commit

Permalink
Clean up hide dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Oct 20, 2023
1 parent 72d5d88 commit 741ef3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -238,7 +238,7 @@ class VpnSettingsViewModel(
contentBlockersOptions = vmState.value.contentBlockersOptions
)

dialogState.update { null }
hideDialog()
}

fun onToggleAutoConnect(isEnabled: Boolean) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 741ef3a

Please sign in to comment.