fix timeline jumping around when new posts are inserted at the top (#4619)

This fixes a bug where the timeline would jump to the position of a
previously clicked "load more" when new post are inserted at the top
after swiping to refresh.

This only happens when "Reading order" is set to "Oldest first".

The problem is that updateReadingPositionForOldestFirst (which consumes
the marker to which it should jump) is called from onItemRangeInserted.
But onItemRangeInserted is not called everytime a "load more" is
clicked, leaving the marker active, causing a jump the next time
onItemRangeInserted is called.

I am not sure this fixes all cases of the various jumping bugs that have
been reported recently as this was the only one I could reliably
reproduce.

Related to https://github.com/tuskyapp/Tusky/issues/4493
This commit is contained in:
Konrad Pozniak 2024-08-19 20:53:11 +02:00 committed by GitHub
parent 3f2b648b19
commit e23686ec70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View File

@ -218,6 +218,7 @@ class NotificationsFragment :
)
}
}
loadMorePosition = null
}
if (readingOrder == ReadingOrder.OLDEST_FIRST) {
updateReadingPositionForOldestFirst(adapter)

View File

@ -266,6 +266,8 @@ class TimelineFragment :
}
}
}
// we loaded new posts at the top - no need to handle "load more" anymore
loadMorePosition = null
}
if (readingOrder == ReadingOrder.OLDEST_FIRST) {
updateReadingPositionForOldestFirst(adapter)