Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Jul 25, 2024
1 parent e289d16 commit 261b639
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ class SelectLocationViewModel(
selectedItem.getOrNull(),
filteredCustomLists,
relayCountries,
{ it in expandedItems })
{ it in expandedItems }
)
if (relayItems.isEmpty()) {
add(RelayListItem.LocationsEmptyText(searchTerm))
} else {
Expand Down Expand Up @@ -195,13 +196,18 @@ class SelectLocationViewModel(
buildList<RelayListItem> {
add(
RelayListItem.CustomListItem(
customList, isSelected = selectedItem == customList.id, expanded))
customList,
isSelected = selectedItem == customList.id,
expanded
)
)

if (expanded) {
addAll(
customList.locations.flatMap {
createCustomListEntry(parent = customList.id, item = it, 1, isExpanded)
})
}
)
}
}
}
Expand All @@ -219,7 +225,8 @@ class SelectLocationViewModel(
addAll(
countries.flatMap { country ->
createGeoLocationEntry(country, selectedItem, isExpanded = isExpanded)
})
}
)
}
}

Expand All @@ -233,20 +240,27 @@ class SelectLocationViewModel(
val expanded = isExpanded(item.id.expandKey(parent))
add(
RelayListItem.CustomListEntryItem(
parentId = parent, item = item, expanded = expanded, depth))
parentId = parent,
item = item,
expanded = expanded,
depth
)
)

if (expanded) {
when (item) {
is RelayItem.Location.City ->
addAll(
item.relays.flatMap {
createCustomListEntry(parent, it, depth + 1, isExpanded)
})
}
)
is RelayItem.Location.Country ->
addAll(
item.cities.flatMap {
createCustomListEntry(parent, it, depth + 1, isExpanded)
})
}
)
is RelayItem.Location.Relay -> {} // No children to add
}
}
Expand All @@ -266,20 +280,23 @@ class SelectLocationViewModel(
isSelected = selectedItem == item.id,
depth = depth,
expanded = expanded,
))
)
)

if (expanded) {
when (item) {
is RelayItem.Location.City ->
addAll(
item.relays.flatMap {
createGeoLocationEntry(it, selectedItem, depth + 1, isExpanded)
})
}
)
is RelayItem.Location.Country ->
addAll(
item.cities.flatMap {
createGeoLocationEntry(it, selectedItem, depth + 1, isExpanded)
})
}
)
is RelayItem.Location.Relay -> {} // Do nothing
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import net.mullvad.mullvadvpn.lib.model.Provider
import net.mullvad.mullvadvpn.lib.model.Providers
import net.mullvad.mullvadvpn.lib.model.RelayItem
import net.mullvad.mullvadvpn.lib.model.RelayItemId
import net.mullvad.mullvadvpn.repository.CustomListsRepository
import net.mullvad.mullvadvpn.repository.RelayListFilterRepository
import net.mullvad.mullvadvpn.repository.RelayListRepository
import net.mullvad.mullvadvpn.usecase.AvailableProvidersUseCase
Expand Down

0 comments on commit 261b639

Please sign in to comment.