mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-05 12:54:35 +00:00
Fix infinite recomposition when on top of the timeline.
This commit is contained in:
committed by
Benoit Marty
parent
d66d28db72
commit
76e4c684d0
+7
-4
@@ -233,12 +233,9 @@ internal fun BoxScope.TimelineScrollHelper(
|
|||||||
val isScrollFinished by remember { derivedStateOf { !lazyListState.isScrollInProgress } }
|
val isScrollFinished by remember { derivedStateOf { !lazyListState.isScrollInProgress } }
|
||||||
val shouldAutoScrollToBottom by remember { derivedStateOf { lazyListState.firstVisibleItemIndex < 2 } }
|
val shouldAutoScrollToBottom by remember { derivedStateOf { lazyListState.firstVisibleItemIndex < 2 } }
|
||||||
|
|
||||||
LaunchedEffect(timelineItems, firstVisibleItemIndex, isScrollFinished) {
|
LaunchedEffect(timelineItems, firstVisibleItemIndex) {
|
||||||
if (!isScrollFinished) return@LaunchedEffect
|
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
|
// Auto-scroll when new timeline items appear
|
||||||
if (shouldAutoScrollToBottom) {
|
if (shouldAutoScrollToBottom) {
|
||||||
coroutineScope.launch {
|
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)
|
// Jump to bottom button (display also in previews)
|
||||||
if (!shouldAutoScrollToBottom || LocalInspectionMode.current) {
|
if (!shouldAutoScrollToBottom || LocalInspectionMode.current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user