Fix infinite recomposition when on top of the timeline.
This commit is contained in:
committed by
Benoit Marty
parent
14d314f87c
commit
b244bdf6a8
@@ -233,12 +233,9 @@ internal fun BoxScope.TimelineScrollHelper(
|
||||
val isScrollFinished by remember { derivedStateOf { !lazyListState.isScrollInProgress } }
|
||||
val shouldAutoScrollToBottom by remember { derivedStateOf { lazyListState.firstVisibleItemIndex < 2 } }
|
||||
|
||||
LaunchedEffect(timelineItems, firstVisibleItemIndex, isScrollFinished) {
|
||||
LaunchedEffect(timelineItems, firstVisibleItemIndex) {
|
||||
if (!isScrollFinished) return@LaunchedEffect
|
||||
|
||||
// Notify the parent composable about the first visible item index when scrolling finishes
|
||||
onScrollFinishedAt(firstVisibleItemIndex)
|
||||
|
||||
// Auto-scroll when new timeline items appear
|
||||
if (shouldAutoScrollToBottom) {
|
||||
coroutineScope.launch {
|
||||
@@ -246,6 +243,12 @@ internal fun BoxScope.TimelineScrollHelper(
|
||||
}
|
||||
}
|
||||
}
|
||||
LaunchedEffect(isScrollFinished) {
|
||||
if (!isScrollFinished) return@LaunchedEffect
|
||||
|
||||
// Notify the parent composable about the first visible item index when scrolling finishes
|
||||
onScrollFinishedAt(firstVisibleItemIndex)
|
||||
}
|
||||
|
||||
// Jump to bottom button (display also in previews)
|
||||
if (!shouldAutoScrollToBottom || LocalInspectionMode.current) {
|
||||
|
||||
Reference in New Issue
Block a user