summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson@mullvad.net>2025-04-16 16:47:01 +0200
committerDavid Göransson <david.goransson@mullvad.net>2025-04-17 16:17:54 +0200
commitd1b0564fc8c1d335cd107707250a514b741ee555 (patch)
treed3ea967f3866feb838160948f1da337a1901bb07 /android
parent0bc5042a286fece386f0f179320f23a3f339f11d (diff)
downloadmullvadvpn-d1b0564fc8c1d335cd107707250a514b741ee555.tar.xz
mullvadvpn-d1b0564fc8c1d335cd107707250a514b741ee555.zip
Fix incorrect getCustomListById
Current implementation would always hold of 5 seconds if we are trying to get a custom list that doesn't exist.
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/CustomListsRepository.kt9
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/customlists/CustomListActionUseCase.kt15
2 files changed, 15 insertions, 9 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 c53d07320f..fe822e489b 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
@@ -32,7 +32,7 @@ class CustomListsRepository(
suspend fun deleteCustomList(id: CustomListId) = managementService.deleteCustomList(id)
- private suspend fun updateCustomList(customList: CustomList) =
+ suspend fun updateCustomList(customList: CustomList) =
managementService.updateCustomList(customList)
suspend fun updateCustomListName(
@@ -57,10 +57,9 @@ class CustomListsRepository(
suspend fun getCustomListById(id: CustomListId): Either<GetCustomListError, CustomList> =
either {
- customLists
- .mapNotNull { it?.find { customList -> customList.id == id } }
- .firstOrNullWithTimeout(GET_CUSTOM_LIST_TIMEOUT_MS)
- ?: raise(GetCustomListError(id))
+ customLists.firstOrNullWithTimeout(GET_CUSTOM_LIST_TIMEOUT_MS)?.find { customList ->
+ customList.id == id
+ } ?: raise(GetCustomListError(id))
}
.mapLeft { GetCustomListError(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 5fb7b0e964..b1326d57b9 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,8 +10,10 @@ 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
@@ -59,8 +61,14 @@ class CustomListActionUseCase(
val locationNames =
if (action.locations.isNotEmpty()) {
customListsRepository
- .updateCustomListLocations(customListId, action.locations)
- .mapLeft(CreateWithLocationsError::UpdateLocations)
+ .updateCustomList(
+ CustomList(
+ id = customListId,
+ name = action.name,
+ locations = action.locations,
+ )
+ )
+ .mapLeft(CreateWithLocationsError::UpdateCustomList)
.bind()
relayListRepository.relayList
@@ -121,8 +129,7 @@ sealed interface CreateWithLocationsError : CustomListActionError {
data class Create(val error: CreateCustomListError) : CreateWithLocationsError
- data class UpdateLocations(val error: UpdateCustomListLocationsError) :
- CreateWithLocationsError
+ data class UpdateCustomList(val error: UpdateCustomListError) : CreateWithLocationsError
data object UnableToFetchRelayList : CreateWithLocationsError
}