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) {