summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2022-11-16 13:39:54 +0100
committerAlbin <albin@mullvad.net>2022-11-16 13:48:52 +0100
commite4e1b25c98b261a48ef6e133a7ea45cc52dbf2d7 (patch)
tree4cb5e45af94056cc9053f693526a8991199a9e3b
parent18b1685dea0d5cae709d5ef8f16d14d4fe003cec (diff)
downloadmullvadvpn-e4e1b25c98b261a48ef6e133a7ea45cc52dbf2d7.tar.xz
mullvadvpn-e4e1b25c98b261a48ef6e133a7ea45cc52dbf2d7.zip
Revert "Set custom dns toggle in onStart"
Reverts non-working fix for custom dns toggle inconsistency. The result is working custom dns toggle behavior which is in sync with the previous releases (2022.2, 2022.3). This reverts commit 880b529651f2db43d51c44d65576aa3ce315f05a.
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt22
1 files changed, 13 insertions, 9 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt
index 4e3fff52c9..30b9608a9d 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt
@@ -16,7 +16,6 @@ import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.shareIn
import kotlinx.coroutines.launch
import net.mullvad.mullvadvpn.R
@@ -57,7 +56,7 @@ class AdvancedFragment : BaseFragment() {
@Deprecated("Refactor code to instead rely on Lifecycle.")
private val jobTracker = JobTracker()
- val sharedCustomDnsInstance = serviceConnectionManager.connectionState
+ val shared = serviceConnectionManager.connectionState
.flatMapLatest { state ->
if (state is ServiceConnectionState.ConnectedReady) {
flowOf(state.container)
@@ -94,12 +93,9 @@ class AdvancedFragment : BaseFragment() {
}
launch {
- sharedCustomDnsInstance
- .flatMapLatest { customDnsInstance ->
- callbackFlowFromNotifier(customDnsInstance.onEnabledChanged)
- .onStart {
- emit(customDnsInstance.isCustomDnsEnabled())
- }
+ shared
+ .flatMapLatest {
+ callbackFlowFromNotifier(it.onEnabledChanged)
}
.collect { isEnabled ->
customDnsAdapter?.updateState(isEnabled)
@@ -114,7 +110,7 @@ class AdvancedFragment : BaseFragment() {
}
launch {
- sharedCustomDnsInstance
+ shared
.flatMapLatest {
callbackFlowFromNotifier(it.onDnsServersChanged)
}
@@ -210,6 +206,14 @@ class AdvancedFragment : BaseFragment() {
}
customDnsToggle = view.findViewById<ToggleCell>(R.id.enable_custom_dns).apply {
+ state = serviceConnectionManager.customDns().let { customDns ->
+ if (customDns?.isCustomDnsEnabled() == true) {
+ CellSwitch.State.ON
+ } else {
+ CellSwitch.State.OFF
+ }
+ }
+
listener = { state ->
jobTracker.newBackgroundJob("toggleCustomDns") {
if (state == CellSwitch.State.ON) {