File tree 2 files changed +14
-10
lines changed
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose
2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,8 @@ fun RelayLocationCell(
290
290
)
291
291
}
292
292
}
293
- else -> {}
293
+ is RelayItem .Relay ,
294
+ is RelayItem .CustomList -> {}
294
295
}
295
296
}
296
297
}
Original file line number Diff line number Diff line change @@ -175,7 +175,10 @@ fun SelectLocationScreen(
175
175
uiState.relayListState.selectedItem != null
176
176
) {
177
177
LaunchedEffect (uiState.relayListState.selectedItem) {
178
- val index = findIndexOfSelectedItemCountry(uiState.relayListState)
178
+ val index =
179
+ uiState.relayListState.indexOfSelectedRelayItem(
180
+ uiState.relayListState.selectedItem
181
+ )
179
182
180
183
if (index >= 0 ) {
181
184
lazyListState.scrollToItem(index)
@@ -275,15 +278,15 @@ private fun LazyListScope.relayList(
275
278
}
276
279
}
277
280
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 ->
280
283
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
287
290
}
288
291
}
289
292
You can’t perform that action at this time.
0 commit comments