Skip to content

Commit

Permalink
Simplify grpc calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Nov 27, 2024
1 parent 9d672ef commit 00a8e02
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import net.mullvad.mullvadvpn.lib.model.CustomList as ModelCustomList
import net.mullvad.mullvadvpn.lib.model.CustomListAlreadyExists
import net.mullvad.mullvadvpn.lib.model.CustomListId
import net.mullvad.mullvadvpn.lib.model.CustomListName
import net.mullvad.mullvadvpn.lib.model.DaitaSettings
import net.mullvad.mullvadvpn.lib.model.DeleteCustomListError
import net.mullvad.mullvadvpn.lib.model.DeleteDeviceError
import net.mullvad.mullvadvpn.lib.model.Device
Expand Down Expand Up @@ -124,7 +123,6 @@ import net.mullvad.mullvadvpn.lib.model.WebsiteAuthToken
import net.mullvad.mullvadvpn.lib.model.WireguardEndpointData as ModelWireguardEndpointData
import net.mullvad.mullvadvpn.lib.model.addresses
import net.mullvad.mullvadvpn.lib.model.customOptions
import net.mullvad.mullvadvpn.lib.model.directOnly
import net.mullvad.mullvadvpn.lib.model.enabled
import net.mullvad.mullvadvpn.lib.model.entryLocation
import net.mullvad.mullvadvpn.lib.model.isMultihopEnabled
Expand Down Expand Up @@ -510,21 +508,12 @@ class ManagementService(
.mapEmpty()

suspend fun setDaitaEnabled(enabled: Boolean): Either<SetDaitaSettingsError, Unit> =
Either.catch {
val currentDaitaSettings = getSettings().tunnelOptions.wireguard.daitaSettings
val updatedDaitaSettings = DaitaSettings.enabled.set(currentDaitaSettings, enabled)
grpc.setDaitaSettings(updatedDaitaSettings.fromDomain())
}
Either.catch { grpc.setEnableDaita(BoolValue.of(enabled)) }
.mapLeft(SetDaitaSettingsError::Unknown)
.mapEmpty()

suspend fun setDaitaDirectOnly(enabled: Boolean): Either<SetDaitaSettingsError, Unit> =
Either.catch {
val currentDaitaSettings = getSettings().tunnelOptions.wireguard.daitaSettings
val updatedDaitaSettings =
DaitaSettings.directOnly.set(currentDaitaSettings, enabled)
grpc.setDaitaSettings(updatedDaitaSettings.fromDomain())
}
Either.catch { grpc.setDaitaDirectOnly(BoolValue.of(enabled)) }
.mapLeft(SetDaitaSettingsError::Unknown)
.mapEmpty()

Expand Down

0 comments on commit 00a8e02

Please sign in to comment.