From a201b3766e8494c86ff366b6d2e385a6c245eb8f Mon Sep 17 00:00:00 2001 From: Jenna Vassar Date: Mon, 8 Jun 2026 06:52:24 -0700 Subject: [PATCH] Fix jump-to-unread requiring two taps for an out-of-window read marker (#6943) * Fix jump-to-unread requiring two taps for an out-of-window read marker * Update features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenter.kt Co-authored-by: Benoit Marty --------- Co-authored-by: Benoit Marty --- .../features/messages/impl/timeline/TimelinePresenter.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenter.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenter.kt index 3ec31b1a99..e8e932b48b 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenter.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelinePresenter.kt @@ -333,7 +333,12 @@ class TimelinePresenter( } } - LaunchedEffect(timelineItems.size, focusRequestState.value) { + // Keyed on the full [timelineItems] reference (not just .size) so we re-resolve the index + // when a focused timeline loads with the same item count as the window it replaced — e.g. + // jumping to an out-of-window read marker in a busy room, where both windows fill to the + // same page size. With .size as the key the effect wouldn't re-run, the focused event's + // index would stay unresolved, and the scroll would never fire until a second tap. + LaunchedEffect(timelineItems.map { it.identifier() }, focusRequestState.value) { val currentFocusRequestState = focusRequestState.value if (currentFocusRequestState is FocusRequestState.Success && !currentFocusRequestState.rendered) { val eventId = currentFocusRequestState.eventId