diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt index 119e358476..039062dc87 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt @@ -235,6 +235,7 @@ private fun BoxScope.TimelineScrollHelper( } } + val latestOnClearFocusRequestState by rememberUpdatedState(onClearFocusRequestState) LaunchedEffect(focusRequestState) { if (focusRequestState is FocusRequestState.Cached) { if (abs(lazyListState.firstVisibleItemIndex - focusRequestState.index) < 10) { @@ -242,7 +243,7 @@ private fun BoxScope.TimelineScrollHelper( } else { lazyListState.scrollToItem(focusRequestState.index) } - onClearFocusRequestState() + latestOnClearFocusRequestState() } } diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemRow.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemRow.kt index 11ea953b2f..4193a9f131 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemRow.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemRow.kt @@ -135,6 +135,7 @@ internal fun TimelineItemRow( } } +@Suppress("ModifierComposable") @Composable private fun Modifier.focusedEvent( focusedEventOffset: Dp diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemVirtualRow.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemVirtualRow.kt index 635cda526e..d56fe00540 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemVirtualRow.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemVirtualRow.kt @@ -20,6 +20,8 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Spacer import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.rememberUpdatedState import androidx.compose.ui.Modifier import io.element.android.features.messages.impl.timeline.TimelineEvents import io.element.android.features.messages.impl.timeline.TimelineRoomInfo @@ -51,8 +53,9 @@ fun TimelineItemVirtualRow( TimelineItemRoomBeginningModel -> TimelineItemRoomBeginningView(roomName = timelineRoomInfo.name) is TimelineItemLoadingIndicatorModel -> { TimelineLoadingMoreIndicator(virtual.model.direction) + val latestEventSink by rememberUpdatedState(eventSink) LaunchedEffect(virtual.model.timestamp) { - eventSink(TimelineEvents.LoadMore(virtual.model.direction)) + latestEventSink(TimelineEvents.LoadMore(virtual.model.direction)) } } is TimelineItemLastForwardIndicatorModel -> { diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimeline.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimeline.kt index 4f67f00e57..39469b552c 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimeline.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimeline.kt @@ -222,7 +222,8 @@ class RustTimeline( isDm = matrixRoom.isDm, hasMoreToLoadBackwards = hasMoreToLoadBackward ) - }.let { items -> loadingIndicatorsPostProcessor.process(items, hasMoreToLoadBackward, hasMoreToLoadForward) } + } + .let { items -> loadingIndicatorsPostProcessor.process(items, hasMoreToLoadBackward, hasMoreToLoadForward) } // Keep lastForwardIndicatorsPostProcessor last .let { items -> lastForwardIndicatorsPostProcessor.process(items) } }