summaryrefslogtreecommitdiffhomepage
path: root/android/app
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2025-03-31 15:59:21 +0200
committerDavid Göransson <david.goransson@mullvad.net>2025-04-01 11:15:05 +0200
commit7cf8e67c7978972dbc4ccf4c5bf9b830d6eef816 (patch)
tree1c89787c2a78f418c48255f8aad415a5440b27aa /android/app
parent548e1b955ff2e3a3a2ac530ea180e3f6c30248b5 (diff)
downloadmullvadvpn-7cf8e67c7978972dbc4ccf4c5bf9b830d6eef816.tar.xz
mullvadvpn-7cf8e67c7978972dbc4ccf4c5bf9b830d6eef816.zip
Set select location to always open on the exit tab
Diffstat (limited to 'android/app')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModel.kt18
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModelTest.kt4
3 files changed, 2 insertions, 22 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt
index 9845ec2d5b..0f836724b7 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt
@@ -229,7 +229,7 @@ val uiModule = module {
viewModel { WireguardCustomPortDialogViewModel(get()) }
viewModel { LoginViewModel(get(), get(), get()) }
viewModel { PrivacyDisclaimerViewModel(get(), IS_PLAY_BUILD) }
- viewModel { SelectLocationViewModel(get(), get(), get(), get(), get(), get(), get()) }
+ viewModel { SelectLocationViewModel(get(), get(), get(), get(), get(), get()) }
viewModel { SettingsViewModel(get(), get(), get(), get(), IS_PLAY_BUILD) }
viewModel { SplashViewModel(get(), get(), get(), get()) }
viewModel { VoucherDialogViewModel(get()) }
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModel.kt
index f78b59c3fb..bf129044ad 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModel.kt
@@ -18,11 +18,9 @@ import net.mullvad.mullvadvpn.compose.state.SelectLocationUiState
import net.mullvad.mullvadvpn.lib.model.Constraint
import net.mullvad.mullvadvpn.lib.model.CustomListId
import net.mullvad.mullvadvpn.lib.model.RelayItem
-import net.mullvad.mullvadvpn.lib.model.Settings
import net.mullvad.mullvadvpn.repository.CustomListsRepository
import net.mullvad.mullvadvpn.repository.RelayListFilterRepository
import net.mullvad.mullvadvpn.repository.RelayListRepository
-import net.mullvad.mullvadvpn.repository.SettingsRepository
import net.mullvad.mullvadvpn.repository.WireguardConstraintsRepository
import net.mullvad.mullvadvpn.usecase.FilterChipUseCase
import net.mullvad.mullvadvpn.usecase.customlists.CustomListActionUseCase
@@ -36,10 +34,9 @@ class SelectLocationViewModel(
private val relayListRepository: RelayListRepository,
private val wireguardConstraintsRepository: WireguardConstraintsRepository,
private val filterChipUseCase: FilterChipUseCase,
- private val settingsRepository: SettingsRepository,
) : ViewModel() {
private val _relayListType: MutableStateFlow<RelayListType> =
- MutableStateFlow(initialRelayListSelection())
+ MutableStateFlow(RelayListType.EXIT)
val uiState =
combine(
@@ -58,15 +55,6 @@ class SelectLocationViewModel(
private val _uiSideEffect = Channel<SelectLocationSideEffect>()
val uiSideEffect = _uiSideEffect.receiveAsFlow()
- private fun initialRelayListSelection() =
- when {
- settingsRepository.settingsUpdates.value?.daitaWithoutDirectOnly() == true ->
- RelayListType.EXIT
- wireguardConstraintsRepository.wireguardConstraints.value?.isMultihopEnabled == true ->
- RelayListType.ENTRY
- else -> RelayListType.EXIT
- }
-
private fun filterChips() = _relayListType.flatMapLatest { filterChipUseCase(it) }
fun selectRelayList(relayListType: RelayListType) {
@@ -130,10 +118,6 @@ class SelectLocationViewModel(
fun removeProviderFilter() {
viewModelScope.launch { relayListFilterRepository.updateSelectedProviders(Constraint.Any) }
}
-
- private fun Settings.daitaWithoutDirectOnly() =
- tunnelOptions.wireguard.daitaSettings.enabled &&
- !tunnelOptions.wireguard.daitaSettings.directOnly
}
sealed interface SelectLocationSideEffect {
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModelTest.kt
index 77a5e948eb..c79d158f82 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModelTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/location/SelectLocationViewModelTest.kt
@@ -34,7 +34,6 @@ import net.mullvad.mullvadvpn.relaylist.descendants
import net.mullvad.mullvadvpn.repository.CustomListsRepository
import net.mullvad.mullvadvpn.repository.RelayListFilterRepository
import net.mullvad.mullvadvpn.repository.RelayListRepository
-import net.mullvad.mullvadvpn.repository.SettingsRepository
import net.mullvad.mullvadvpn.repository.WireguardConstraintsRepository
import net.mullvad.mullvadvpn.usecase.FilterChip
import net.mullvad.mullvadvpn.usecase.FilterChipUseCase
@@ -54,7 +53,6 @@ class SelectLocationViewModelTest {
private val mockCustomListsRepository: CustomListsRepository = mockk()
private val mockWireguardConstraintsRepository: WireguardConstraintsRepository = mockk()
private val mockFilterChipUseCase: FilterChipUseCase = mockk()
- private val mocksSettingsRepository: SettingsRepository = mockk()
private lateinit var viewModel: SelectLocationViewModel
@@ -69,7 +67,6 @@ class SelectLocationViewModelTest {
every { mockWireguardConstraintsRepository.wireguardConstraints } returns
wireguardConstraints
every { mockFilterChipUseCase(any()) } returns filterChips
- every { mocksSettingsRepository.settingsUpdates } returns MutableStateFlow(null)
mockkStatic(RELAY_LIST_EXTENSIONS)
mockkStatic(RELAY_ITEM_EXTENSIONS)
@@ -82,7 +79,6 @@ class SelectLocationViewModelTest {
customListsRepository = mockCustomListsRepository,
filterChipUseCase = mockFilterChipUseCase,
wireguardConstraintsRepository = mockWireguardConstraintsRepository,
- settingsRepository = mocksSettingsRepository,
)
}