diff options
| author | Albin <albin@mullvad.net> | 2023-07-25 07:49:40 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2023-08-01 11:45:31 +0200 |
| commit | a406d6df7995d0112c4b1dafb1636d8d92bec94b (patch) | |
| tree | 3cb1cefb6c7e7548f803b64855897a39c739af82 /android | |
| parent | 4d0ef3cc74a98754dc5e6faba6730bbfda2ad992 (diff) | |
| download | mullvadvpn-a406d6df7995d0112c4b1dafb1636d8d92bec94b.tar.xz mullvadvpn-a406d6df7995d0112c4b1dafb1636d8d92bec94b.zip | |
Filter out empty and short-name country locations
Diffstat (limited to 'android')
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt index b6da4753a8..8bba8fc437 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt @@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.emptyFlow +import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.shareIn @@ -97,10 +98,13 @@ class ConnectViewModel(private val serviceConnectionManager: ServiceConnectionMa .debounce(UI_STATE_DEBOUNCE_DURATION_MILLIS) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), ConnectUiState.INITIAL) - private fun LocationInfoCache.locationCallbackFlow() = callbackFlow { - onNewLocation = { this.trySend(it) } - awaitClose { onNewLocation = null } - } + private fun LocationInfoCache.locationCallbackFlow() = + callbackFlow { + onNewLocation = { this.trySend(it) } + awaitClose { onNewLocation = null } + } + // Filter out empty or short-name country representations. + .filter { it?.let { location -> location.country.length > 2 } ?: false } private fun RelayListListener.relayListCallbackFlow() = callbackFlow { onRelayCountriesChange = { _, item -> this.trySend(item) } |
