mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-20 09:15:26 +02:00
Fixed recomposition logic when toggling favorites filter
This commit is contained in:
parent
89036b6ea6
commit
c5e0291789
@ -64,7 +64,7 @@ import com.sadellie.unitto.feature.unitslist.components.UnitListItem
|
|||||||
@Composable
|
@Composable
|
||||||
internal fun LeftSideScreen(
|
internal fun LeftSideScreen(
|
||||||
viewModel: UnitsListViewModel,
|
viewModel: UnitsListViewModel,
|
||||||
currentUnitId: String,
|
currentUnitId: String?,
|
||||||
navigateUp: () -> Unit,
|
navigateUp: () -> Unit,
|
||||||
navigateToSettingsAction: () -> Unit,
|
navigateToSettingsAction: () -> Unit,
|
||||||
selectAction: (AbstractUnit) -> Unit
|
selectAction: (AbstractUnit) -> Unit
|
||||||
@ -142,8 +142,11 @@ internal fun LeftSideScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This block is called only once on initial composition
|
LaunchedEffect(uiState.value.shownUnitGroups, currentUnitId) {
|
||||||
LaunchedEffect(uiState.value.shownUnitGroups) {
|
if (currentUnitId == null) return@LaunchedEffect
|
||||||
|
// This is still wrong, but works good enough.
|
||||||
|
// Ideally we shouldn't use uiState.value.shownUnitGroups
|
||||||
|
viewModel.setSelectedChip(currentUnitId)
|
||||||
val groupToSelect = uiState.value.shownUnitGroups.indexOf(uiState.value.chosenUnitGroup)
|
val groupToSelect = uiState.value.shownUnitGroups.indexOf(uiState.value.chosenUnitGroup)
|
||||||
if (groupToSelect > -1) {
|
if (groupToSelect > -1) {
|
||||||
chipsRowLazyListState.animateScrollToItem(groupToSelect)
|
chipsRowLazyListState.animateScrollToItem(groupToSelect)
|
||||||
|
@ -50,11 +50,9 @@ fun NavGraphBuilder.leftScreen(
|
|||||||
composable(
|
composable(
|
||||||
route = "$leftSideRoute/{$unitFromIdArg}"
|
route = "$leftSideRoute/{$unitFromIdArg}"
|
||||||
) {
|
) {
|
||||||
val unitFromId = it.arguments?.getString(unitFromIdArg) ?: return@composable
|
|
||||||
viewModel.setSelectedChip(unitFromId)
|
|
||||||
LeftSideScreen(
|
LeftSideScreen(
|
||||||
viewModel = viewModel,
|
viewModel = viewModel,
|
||||||
currentUnitId = unitFromId,
|
currentUnitId = it.arguments?.getString(unitFromIdArg),
|
||||||
navigateUp = navigateUp,
|
navigateUp = navigateUp,
|
||||||
navigateToSettingsAction = navigateToUnitGroups,
|
navigateToSettingsAction = navigateToUnitGroups,
|
||||||
selectAction = onSelect
|
selectAction = onSelect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user