mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-20 01:05: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
|
||||
internal fun LeftSideScreen(
|
||||
viewModel: UnitsListViewModel,
|
||||
currentUnitId: String,
|
||||
currentUnitId: String?,
|
||||
navigateUp: () -> Unit,
|
||||
navigateToSettingsAction: () -> Unit,
|
||||
selectAction: (AbstractUnit) -> Unit
|
||||
@ -142,8 +142,11 @@ internal fun LeftSideScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// This block is called only once on initial composition
|
||||
LaunchedEffect(uiState.value.shownUnitGroups) {
|
||||
LaunchedEffect(uiState.value.shownUnitGroups, currentUnitId) {
|
||||
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)
|
||||
if (groupToSelect > -1) {
|
||||
chipsRowLazyListState.animateScrollToItem(groupToSelect)
|
||||
|
@ -50,11 +50,9 @@ fun NavGraphBuilder.leftScreen(
|
||||
composable(
|
||||
route = "$leftSideRoute/{$unitFromIdArg}"
|
||||
) {
|
||||
val unitFromId = it.arguments?.getString(unitFromIdArg) ?: return@composable
|
||||
viewModel.setSelectedChip(unitFromId)
|
||||
LeftSideScreen(
|
||||
viewModel = viewModel,
|
||||
currentUnitId = unitFromId,
|
||||
currentUnitId = it.arguments?.getString(unitFromIdArg),
|
||||
navigateUp = navigateUp,
|
||||
navigateToSettingsAction = navigateToUnitGroups,
|
||||
selectAction = onSelect
|
||||
|
Loading…
x
Reference in New Issue
Block a user