Fix paginating (Est: 8, Act: 13)
As we use sync filters and limit timeline count to 20 on incremental sync, each sync may well be incomplete (e.g. when network drops).
initial-sync----> A1 ----sync----> B1-B20 ^ ^ pA pB
pA and pB mean prevBatch for A and Bs, respectively.
In the operation above, there might be a gap between A1 and B1, if there are more than 20 events sent to the room in the meantime. At least for synapse, it will return only the latest 20 events in the timeline.
We must have a way to identify the gap and close it (fetching all the messages in between).
There is a
limited property on Timeline in the response of Sync.
For each sync batch B, we could record pB and associate it with the first event in the batch, B1, whenever B.limited is true.
Then for every recorded pB, when the user has scrolled to B1, make a pagination request from pB backwards with a limit N. Erase pB.
- If the response gives out a list (C1(oldest)-CN(latest)) with no known events, record pC and associate it with C1.
- Add a member of type map to RoomModel to represent Gaps (at eventId) and their corresponding prevBatch
- Make Sync record Gaps if the event batch is limited; and corresponding unit test
- Make an Action to try to close the Gap in the timeline; and reducer; and tests
- Add a method in Room to paginate back from a gapped event
Record new prevBatch only when we do not come across a known eventRemove all gaps between the first event of the newly-fetched batch (C1) and the first event of the original batch (B1), if any
- Make sortedUniqueMerge() more efficient