diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2022-08-10 16:38:11 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2022-08-10 16:38:11 +0200 |
| commit | 0b33e493f0a0c73ca74bd85ccc56bca94436839c (patch) | |
| tree | 7acded131a013a865a07cc14085290ffbda2d004 | |
| parent | 4a5604674b32b4b8c53b536963654501eb9fd206 (diff) | |
| parent | 880b529651f2db43d51c44d65576aa3ce315f05a (diff) | |
| download | mullvadvpn-0b33e493f0a0c73ca74bd85ccc56bca94436839c.tar.xz mullvadvpn-0b33e493f0a0c73ca74bd85ccc56bca94436839c.zip | |
Merge branch 'fix-custom-dns-toggle'
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt | 14 | ||||
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/CustomDns.kt | 4 |
2 files changed, 13 insertions, 5 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 12282c30a9..4e3fff52c9 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,6 +16,7 @@ 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 @@ -56,7 +57,7 @@ class AdvancedFragment : BaseFragment() { @Deprecated("Refactor code to instead rely on Lifecycle.") private val jobTracker = JobTracker() - val shared = serviceConnectionManager.connectionState + val sharedCustomDnsInstance = serviceConnectionManager.connectionState .flatMapLatest { state -> if (state is ServiceConnectionState.ConnectedReady) { flowOf(state.container) @@ -93,9 +94,12 @@ class AdvancedFragment : BaseFragment() { } launch { - shared - .flatMapLatest { - callbackFlowFromNotifier(it.onEnabledChanged) + sharedCustomDnsInstance + .flatMapLatest { customDnsInstance -> + callbackFlowFromNotifier(customDnsInstance.onEnabledChanged) + .onStart { + emit(customDnsInstance.isCustomDnsEnabled()) + } } .collect { isEnabled -> customDnsAdapter?.updateState(isEnabled) @@ -110,7 +114,7 @@ class AdvancedFragment : BaseFragment() { } launch { - shared + sharedCustomDnsInstance .flatMapLatest { callbackFlowFromNotifier(it.onDnsServersChanged) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/CustomDns.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/CustomDns.kt index f33c2967fa..2675c1231a 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/CustomDns.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/CustomDns.kt @@ -28,6 +28,10 @@ class CustomDns(private val connection: Messenger, private val settingsListener: connection.send(Request.SetEnableCustomDns(false).message) } + fun isCustomDnsEnabled(): Boolean { + return onEnabledChanged.latestEvent ?: false + } + fun addDnsServer(server: InetAddress): Boolean { val didntAlreadyHaveServer = !onDnsServersChanged.latestEvent.contains(server) |
