Fix crash on chips scroll

This commit is contained in:
Sad Ellie 2023-09-16 18:48:55 +03:00
parent 7e6036f4ce
commit 75ed884611

View File

@ -102,15 +102,16 @@ private fun LeftSideScreen(
val chipsRowLazyListState = rememberLazyListState() val chipsRowLazyListState = rememberLazyListState()
LaunchedEffect(uiState.unitFrom, uiState.shownUnitGroups) { LaunchedEffect(uiState.unitFrom, uiState.shownUnitGroups) {
// TODO Scroll to initially selected unit group
if (uiState.unitFrom == null) return@LaunchedEffect if (uiState.unitFrom == null) return@LaunchedEffect
updateUnitGroup(uiState.unitFrom.group) updateUnitGroup(uiState.unitFrom.group)
val groupToSelect = uiState.shownUnitGroups.indexOf(uiState.unitFrom.group) val groupToSelect = uiState.shownUnitGroups.indexOf(uiState.unitFrom.group)
if (groupToSelect > -1) { if (groupToSelect > -1) {
kotlin.runCatching {
chipsRowLazyListState.animateScrollToItem(groupToSelect) chipsRowLazyListState.animateScrollToItem(groupToSelect)
} }
} }
}
Scaffold( Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),