diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-06-17 16:55:21 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-06-24 14:22:23 +0200 |
| commit | 14fcbe159ea35ebd4e4d0adebd182e47631335cb (patch) | |
| tree | acc327998e3fa82c06c61c064bf0b370b6adc18b /android/app/src/main/kotlin | |
| parent | 41a021c7d4efdb74b1c71e7567d22ffc930411c4 (diff) | |
| download | mullvadvpn-14fcbe159ea35ebd4e4d0adebd182e47631335cb.tar.xz mullvadvpn-14fcbe159ea35ebd4e4d0adebd182e47631335cb.zip | |
Enable support for creating a custom list with locations
Diffstat (limited to 'android/app/src/main/kotlin')
2 files changed, 5 insertions, 17 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/CustomListsRepository.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/CustomListsRepository.kt index 32dd9a8e0e..6b8fd69ff8 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/CustomListsRepository.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/CustomListsRepository.kt @@ -28,7 +28,10 @@ class CustomListsRepository( .mapNotNull { it.customLists } .stateIn(CoroutineScope(dispatcher), SharingStarted.Eagerly, null) - suspend fun createCustomList(name: CustomListName) = managementService.createCustomList(name) + suspend fun createCustomList( + name: CustomListName, + locations: List<GeoLocationId> = emptyList(), + ) = managementService.createCustomList(name, locations) suspend fun deleteCustomList(id: CustomListId) = managementService.deleteCustomList(id) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/customlists/CustomListActionUseCase.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/customlists/CustomListActionUseCase.kt index b1326d57b9..da1b6fcb56 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/customlists/CustomListActionUseCase.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/customlists/CustomListActionUseCase.kt @@ -10,10 +10,8 @@ import net.mullvad.mullvadvpn.compose.communication.Deleted import net.mullvad.mullvadvpn.compose.communication.LocationsChanged import net.mullvad.mullvadvpn.compose.communication.Renamed import net.mullvad.mullvadvpn.lib.model.CreateCustomListError -import net.mullvad.mullvadvpn.lib.model.CustomList import net.mullvad.mullvadvpn.lib.model.DeleteCustomListError import net.mullvad.mullvadvpn.lib.model.GetCustomListError -import net.mullvad.mullvadvpn.lib.model.UpdateCustomListError import net.mullvad.mullvadvpn.lib.model.UpdateCustomListLocationsError import net.mullvad.mullvadvpn.lib.model.UpdateCustomListNameError import net.mullvad.mullvadvpn.relaylist.getRelayItemsByCodes @@ -54,23 +52,12 @@ class CustomListActionUseCase( ): Either<CreateWithLocationsError, Created> = either { val customListId = customListsRepository - .createCustomList(action.name) + .createCustomList(action.name, action.locations) .mapLeft(CreateWithLocationsError::Create) .bind() val locationNames = if (action.locations.isNotEmpty()) { - customListsRepository - .updateCustomList( - CustomList( - id = customListId, - name = action.name, - locations = action.locations, - ) - ) - .mapLeft(CreateWithLocationsError::UpdateCustomList) - .bind() - relayListRepository.relayList .firstOrNull() ?.getRelayItemsByCodes(action.locations) @@ -129,8 +116,6 @@ sealed interface CreateWithLocationsError : CustomListActionError { data class Create(val error: CreateCustomListError) : CreateWithLocationsError - data class UpdateCustomList(val error: UpdateCustomListError) : CreateWithLocationsError - data object UnableToFetchRelayList : CreateWithLocationsError } |
