diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/RelayListListener.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/RelayListListener.kt index 30b8540bf986..d04e7394f9f3 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/RelayListListener.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/RelayListListener.kt @@ -42,12 +42,11 @@ class RelayListListener( messageHandler.trySendRequest(Request.SetWireguardConstraints(value)) } - fun updateSelectedOwnershipFilter(value: Constraint) { - messageHandler.trySendRequest(Request.SetOwnership(value)) - } - - fun updateSelectedProvidersFilter(value: Constraint) { - messageHandler.trySendRequest(Request.SetProviders(value)) + fun updateSelectedOwnershipAndProviderFilter( + ownership: Constraint, + providers: Constraint + ) { + messageHandler.trySendRequest(Request.SetOwnershipAndProviders(ownership, providers)) } private fun defaultRelayList() = RelayList(ArrayList(), WireguardEndpointData(ArrayList())) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/RelayListFilterUseCase.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/RelayListFilterUseCase.kt index a26f302f9ca4..f480e6a23a66 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/RelayListFilterUseCase.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/RelayListFilterUseCase.kt @@ -15,12 +15,11 @@ class RelayListFilterUseCase( private val relayListListener: RelayListListener, private val settingsRepository: SettingsRepository ) { - fun updateOwnershipFilter(ownership: Constraint) { - relayListListener.updateSelectedOwnershipFilter(ownership) - } - - fun updateProviderFilter(providers: Constraint) { - relayListListener.updateSelectedProvidersFilter(providers) + fun updateOwnershipAndProviderFilter( + ownership: Constraint, + providers: Constraint + ) { + relayListListener.updateSelectedOwnershipAndProviderFilter(ownership, providers) } fun selectedOwnership(): Flow> = diff --git a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt index b73010785a5d..267f1f2619a8 100644 --- a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt +++ b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt @@ -103,12 +103,14 @@ sealed class Request : Message.RequestMessage() { data class SetWireGuardQuantumResistant(val quantumResistant: QuantumResistantState) : Request() - @Parcelize data class SetOwnership(val ownership: Constraint) : Request() - - @Parcelize data class SetProviders(val providers: Constraint) : Request() - @Parcelize data object FetchRelayList : Request() + @Parcelize + data class SetOwnershipAndProviders( + val ownership: Constraint, + val providers: Constraint + ) : Request() + companion object { private const val MESSAGE_KEY = "request" diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/RelayListListener.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/RelayListListener.kt index 186ac21092cf..2f18c090640a 100644 --- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/RelayListListener.kt +++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/RelayListListener.kt @@ -67,25 +67,20 @@ class RelayListListener( } scope.launch { - endpoint.dispatcher.parsedMessages.filterIsInstance().collect { - request -> - val update = getCurrentRelayConstraints().copy(ownership = request.ownership) - daemon.await().setRelaySettings(RelaySettings.Normal(update)) - } - } - - scope.launch { - endpoint.dispatcher.parsedMessages.filterIsInstance().collect { - request -> - val update = getCurrentRelayConstraints().copy(providers = request.providers) - daemon.await().setRelaySettings(RelaySettings.Normal(update)) + endpoint.dispatcher.parsedMessages.filterIsInstance().collect { + relayList = daemon.await().getRelayLocations() } } scope.launch { - endpoint.dispatcher.parsedMessages.filterIsInstance().collect { - relayList = daemon.await().getRelayLocations() - } + endpoint.dispatcher.parsedMessages + .filterIsInstance() + .collect { request -> + val update = + getCurrentRelayConstraints() + .copy(ownership = request.ownership, providers = request.providers) + daemon.await().setRelaySettings(RelaySettings.Normal(update)) + } } }