From cccf5de015f36c259b413057010ce917916ac5bf Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 24 Jun 2021 18:46:32 +0200 Subject: [PATCH] Jump to unread: removes unnecessary check which can cause scroll issue --- .../detail/ScrollOnHighlightedEventCallback.kt | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnHighlightedEventCallback.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnHighlightedEventCallback.kt index 5d3a91f18d..7f652a2eea 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnHighlightedEventCallback.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnHighlightedEventCallback.kt @@ -20,7 +20,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import im.vector.app.core.platform.DefaultListUpdateCallback import im.vector.app.features.home.room.detail.timeline.TimelineEventController -import timber.log.Timber import java.util.concurrent.atomic.AtomicReference /** @@ -42,19 +41,10 @@ class ScrollOnHighlightedEventCallback(private val recyclerView: RecyclerView, private fun scrollIfNeeded() { val eventId = scheduledEventId.get() ?: return - val positionToScroll = timelineEventController.searchPositionOfEvent(eventId) - if (positionToScroll != null) { - val firstVisibleItem = layoutManager.findFirstCompletelyVisibleItemPosition() - val lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition() - - // Do not scroll it item is already visible - if (positionToScroll !in firstVisibleItem..lastVisibleItem) { - Timber.v("Scroll to $positionToScroll") - recyclerView.stopScroll() - layoutManager.scrollToPosition(positionToScroll) - } - scheduledEventId.set(null) - } + val positionToScroll = timelineEventController.searchPositionOfEvent(eventId) ?: return + recyclerView.stopScroll() + layoutManager.scrollToPosition(positionToScroll) + scheduledEventId.set(null) } fun scheduleScrollTo(eventId: String?) {