Skip to content

Commit e9076e2

Browse files
committed
Fixed some more issues
1 parent 6946f97 commit e9076e2

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ fun RelayLocationCell(
290290
)
291291
}
292292
}
293-
else -> {}
293+
is RelayItem.Relay,
294+
is RelayItem.CustomList -> {}
294295
}
295296
}
296297
}

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt

+12-9
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ fun SelectLocationScreen(
175175
uiState.relayListState.selectedItem != null
176176
) {
177177
LaunchedEffect(uiState.relayListState.selectedItem) {
178-
val index = findIndexOfSelectedItemCountry(uiState.relayListState)
178+
val index =
179+
uiState.relayListState.indexOfSelectedRelayItem(
180+
uiState.relayListState.selectedItem
181+
)
179182

180183
if (index >= 0) {
181184
lazyListState.scrollToItem(index)
@@ -275,15 +278,15 @@ private fun LazyListScope.relayList(
275278
}
276279
}
277280

278-
private fun findIndexOfSelectedItemCountry(relayListState: RelayListState.RelayList): Int =
279-
relayListState.countries.indexOfFirst { relayCountry ->
281+
private fun RelayListState.RelayList.indexOfSelectedRelayItem(selectedItem: RelayItem?): Int =
282+
countries.indexOfFirst { relayCountry ->
280283
relayCountry.location.location.country ==
281-
when (relayListState.selectedItem) {
282-
is RelayItem.CustomList -> null
283-
is RelayItem.Country -> relayListState.selectedItem.code
284-
is RelayItem.City -> relayListState.selectedItem.location.countryCode
285-
is RelayItem.Relay -> relayListState.selectedItem.location.countryCode
286-
else -> null
284+
when (selectedItem) {
285+
is RelayItem.Country -> selectedItem.code
286+
is RelayItem.City -> selectedItem.location.countryCode
287+
is RelayItem.Relay -> selectedItem.location.countryCode
288+
is RelayItem.CustomList,
289+
null -> null
287290
}
288291
}
289292

0 commit comments

Comments
 (0)