-
Notifications
You must be signed in to change notification settings - Fork 10
Jumping forward and backward isn't stable and not completely seamless #120
Description
#114 mentioned "seamless navigation" with a caveat but jumping forward and backward in a normal room doesn't seem to land you in the same spot. And it's not obvious that you skipped over a couple messages in that gap either.
For example if I visit /r/test-room1:my.synapse.server/date/2021/12/09, jump to next, the jump back to previous, I'm now on /r/test-room1:my.synapse.server/date/2021/12/14.
This is caused because when we /messages?dir=f to jump forwards, the date picked is rounded to the end of the day and there are more messages in between than the limit. So we end up missing messages in the gap between the limit and where we jumped from.
Example:
- Archive message limit: 6
- Visit
/r/foo:bar/date/<day1>: Will render from day 1 going backwards 6 messages (only 4 messages to show until we hit the start of the room) - Jump forwards, will go forward 6 messages and pick that timestamp to redirect to
/r/foo:bar/date/<day3>: Will render from day 3 going backwards 6 messages
1 <-- 2 <-- 3 <-- 4 <-- 5 <-- 6 <-- 7 <-- 8 <-- 9 <-- 10 <-- 11 <-- 12
[day 1 ] [day 2 ] [day 3 ]
[page1 ]
|------jump-forwards-6-messages----->|
[page2 ]
﹍﹍﹍﹍﹍﹍﹍﹍﹍
gap
Potential solution
When jumping forwards (/messages?dir=f&limit=100), back track a bit until we can find a date boundary. This will guarantee some overlap with the previous page.
We then need to adjust the ?continue=top query parameter to take an event ID (?continue=$abc) to continue from so we can start the scroll off there.
Using the previous example, it would now look like this:
1 <-- 2 <-- 3 <-- 4 <-- 5 <-- 6 <-- 7 <-- 8 <-- 9 <-- 10 <-- 11 <-- 12
[day 1 ] [day 2 ] [day 3 ]
[page1 ]
|------jump forwards 6 messages----->|
|<-backtrack-|
[page2, start scroll at 5 ]