Skip to content

Commit

Permalink
Fix duplicate entries when adding through bottom sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Apr 19, 2024
1 parent d54dcc6 commit 8ff134e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import net.mullvad.mullvadvpn.model.Constraint
import net.mullvad.mullvadvpn.model.Ownership
import net.mullvad.mullvadvpn.relaylist.Provider
import net.mullvad.mullvadvpn.relaylist.RelayItem
import net.mullvad.mullvadvpn.relaylist.descendants
import net.mullvad.mullvadvpn.relaylist.filterOnOwnershipAndProvider
import net.mullvad.mullvadvpn.relaylist.filterOnSearchTerm
import net.mullvad.mullvadvpn.relaylist.toLocationConstraint
Expand Down Expand Up @@ -137,7 +138,8 @@ class SelectLocationViewModel(

fun addLocationToList(item: RelayItem, customList: RelayItem.CustomList) {
viewModelScope.launch {
val newLocations = (customList.locations + item).map { it.code }
val newLocations =
(customList.locations + item).filter { it !in item.descendants() }.map { it.code }
val result =
customListActionUseCase.performAction(
CustomListAction.UpdateLocations(customList.id, newLocations)
Expand Down

0 comments on commit 8ff134e

Please sign in to comment.