summaryrefslogtreecommitdiffhomepage
path: root/android/app
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2025-06-17 16:55:21 +0200
committerJonatan Rhodin <jonatan.rhodin@mullvad.net>2025-06-24 14:22:23 +0200
commit14fcbe159ea35ebd4e4d0adebd182e47631335cb (patch)
treeacc327998e3fa82c06c61c064bf0b370b6adc18b /android/app
parent41a021c7d4efdb74b1c71e7567d22ffc930411c4 (diff)
downloadmullvadvpn-14fcbe159ea35ebd4e4d0adebd182e47631335cb.tar.xz
mullvadvpn-14fcbe159ea35ebd4e4d0adebd182e47631335cb.zip
Enable support for creating a custom list with locations
Diffstat (limited to 'android/app')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/CustomListsRepository.kt5
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/customlists/CustomListActionUseCase.kt17
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/CustomListActionUseCaseTest.kt10
3 files changed, 8 insertions, 24 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
}
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/CustomListActionUseCaseTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/CustomListActionUseCaseTest.kt
index 03d46cbde0..d9a687362a 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/CustomListActionUseCaseTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/CustomListActionUseCaseTest.kt
@@ -62,12 +62,8 @@ class CustomListActionUseCaseTest {
undo = action.not(createdId),
)
.right()
- coEvery { mockCustomListsRepository.createCustomList(name) } returns createdId.right()
- coEvery {
- mockCustomListsRepository.updateCustomList(
- CustomList(createdId, name, listOf(locationId))
- )
- } returns Unit.right()
+ coEvery { mockCustomListsRepository.createCustomList(name, listOf(locationId)) } returns
+ createdId.right()
relayListFlow.value =
listOf(
RelayItem.Location.Country(
@@ -91,7 +87,7 @@ class CustomListActionUseCaseTest {
val locationId = GeoLocationId.Country("AB")
val action = CustomListAction.Create(name = name, locations = listOf(locationId))
val expectedError = CreateWithLocationsError.Create(CustomListAlreadyExists).left()
- coEvery { mockCustomListsRepository.createCustomList(name) } returns
+ coEvery { mockCustomListsRepository.createCustomList(name, listOf(locationId)) } returns
CustomListAlreadyExists.left()
// Act