diff options
| author | David Göransson <david.goransson@mullvad.net> | 2025-03-04 14:23:58 +0100 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2025-03-04 14:24:31 +0100 |
| commit | 4f82b6b7c857ca15912dfe291127980f47b12e8d (patch) | |
| tree | 634dbb9b904b9db4479b7cc4ad77b422656187e4 /android/lib/common/src | |
| parent | 01e094c47d03faa82121036da8dd1dd98ca164ad (diff) | |
| download | mullvadvpn-4f82b6b7c857ca15912dfe291127980f47b12e8d.tar.xz mullvadvpn-4f82b6b7c857ca15912dfe291127980f47b12e8d.zip | |
Improve connectivity listener online detection
Fixes incorrect filter for networkEvents. Also adds debouncing to
offline state when roaming to cellular from WiFi, this would otherwise
cause a full reconnection.
Diffstat (limited to 'android/lib/common/src')
| -rw-r--r-- | android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/CommonFlowUtils.kt | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/CommonFlowUtils.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/CommonFlowUtils.kt index 863fc32251..bf94c80778 100644 --- a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/CommonFlowUtils.kt +++ b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/CommonFlowUtils.kt @@ -1,26 +1,9 @@ package net.mullvad.mullvadvpn.lib.common.util -import kotlin.time.Duration -import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.firstOrNull -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.withIndex import kotlinx.coroutines.withTimeoutOrNull suspend fun <T> Flow<T>.firstOrNullWithTimeout(timeMillis: Long): T? { return withTimeoutOrNull(timeMillis) { firstOrNull() } } - -@OptIn(FlowPreview::class) -fun <T> Flow<T>.debounceFirst(timeout: Duration): Flow<T> = - withIndex() - .debounce { - if (it.index == 0) { - timeout - } else { - Duration.ZERO - } - } - .map { it.value } |
