1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Stash the old next_batch token for pagination

When we reset the live timeline due to a limited sync, stash next_batch as the
pagination token so that we can work forward to the new live timeline.

(Note that this requires matrix-org/synapse#535)
This commit is contained in:
Richard van der Hoff
2016-01-30 00:04:59 +00:00
parent 1499087098
commit 2af947fc1a

View File

@@ -361,10 +361,12 @@ SyncApi.prototype._sync = function(syncOptions, attempt) {
filterId = this._getGuestFilter();
}
var syncToken = client.store.getSyncToken();
var qps = {
filter: filterId,
timeout: this.opts.pollTimeout,
since: client.store.getSyncToken() || undefined // do not send 'null'
since: syncToken || undefined // do not send 'null'
};
if (attempt > 1) {
@@ -557,6 +559,11 @@ SyncApi.prototype._processSyncResponse = function(data) {
if (joinObj.timeline.limited) {
// nuke the timeline so we don't get holes
//
// save the old 'next_batch' token as the
// forward-pagination token for the previously-active
// timeline.
room.currentState.paginationToken = syncToken;
self._deregisterStateListeners(room);
room.resetLiveTimeline();
self._registerStateListeners(room);
@@ -727,7 +734,8 @@ SyncApi.prototype._resolveInvites = function(room) {
* at the *START* of the timeline list if it is supplied.
* @param {?MatrixEvent[]} timelineEventList A list of timeline events. Lower index
* is earlier in time. Higher index is later.
* @param {string=} paginationToken
* @param {string=} paginationToken pagination token for going backwards in time.
* This should only be set if this is a new room/timeline.
*/
SyncApi.prototype._processRoomEvents = function(room, stateEventList,
timelineEventList, paginationToken) {