From 2af947fc1a49ff50bf2caca105c1cc9bec83025b Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Sat, 30 Jan 2016 00:04:59 +0000 Subject: [PATCH] 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) --- lib/sync.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/sync.js b/lib/sync.js index e48f0a996..95d07e281 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -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) {