megalodon icon indicating copy to clipboard operation
megalodon copied to clipboard

Remember scroll position

Open sboulema opened this issue 2 years ago • 8 comments

Remember scroll position when reading toots, so you can easily read everything after loading new toots.

sboulema avatar Nov 22 '22 11:11 sboulema

This would be a game changer!

magbeat avatar Nov 22 '22 21:11 magbeat

so basically: when refreshing (when dragging down), don't scroll up, right? will have to look into this, but i'd love this as well!

sk22 avatar Nov 22 '22 22:11 sk22

And it would be perfect if the time line would be loaded from "past to present" so that you could continue scrolling till you're at the newest post.

Kobaltauge avatar Nov 27 '22 11:11 Kobaltauge

Related: when switching between two accounts, scroll position is also reset.

For instance:

  • I'm in account A, but not on top (there are still posts that I haven't read above)
  • I switch to account B
  • Then switch back to account A: I am now at the top. My previous position has been lost.

s427 avatar Oct 02 '23 11:10 s427

I came from comment https://github.com/mastodon/mastodon-android/pull/680#issuecomment-1712281383 expecting newer Megalodon versions to have this awesome load direction UI and a timeline that remembers / doesn't jump to the top on its own, but sadly it does jump to the top on almost every occasion (going to settings and back, restarting app). Since this issue isn't closed I suppose this remains to be implemented. Big +1, I have yet to find an Android app that does this correctly. Well-behaved apps are sadly iOS-only (Toot!, Metatext).

zopieux avatar Feb 09 '24 01:02 zopieux

I can't verify it now, but I think that this used to work when that setting you mentioned was released. For me it stopped working a few weeks ago, or at least the resetting became more frequent. Again I don't know how I'd verify that now but curious if that's been the same for anyone else.

Fedilab on Android does do this correctly I believe.

danielfalk avatar Feb 09 '24 15:02 danielfalk

Thanks @danielfalk, gave Fedilab a try and I can confirm it correctly saves the timeline position remotely to the markers API. However, while Fedilab has code for retrieving the marker, it doesn't use it, instead it relies on a device-only shared preference. In other words, Fedilab's position saving is write-only. Not that I care that much now that I found the one and only app to actually save & restore my timeline position.

zopieux avatar Feb 09 '24 20:02 zopieux

I gave the code a look:

  • Just like Fedilab, Megalodon saves both the notification & timeline positions to the markers API.
  • Just like Fedilab, Megalodon does not use the (possibly updated) timeline position from the markers API. It makes a GET call but only uses the notification position.
  • Unlike Fedilab, and this is the most important point and what this issue is about, Megalodon doesn't attempt to remember the timeline position locally whatsoever. This would be a matter of saving it locally (database or shared pref) around here, and patching the timeline loading logic (too complicated to link) to scroll to that position at fragment creation. Fedilab's logic for this FYI.

zopieux avatar Feb 09 '24 21:02 zopieux