From a00e318d735b0772f208bc061517686f81a2ab2b Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 14 Dec 2015 12:28:04 +0000 Subject: [PATCH] Fix pagination - set prev_batch at the right time --- lib/sync.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/sync.js b/lib/sync.js index cd4c6e22a..9335cdd8f 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -301,9 +301,16 @@ SyncApi.prototype._sync = function(syncOptions, attempt) { // nuke the timeline so we don't get holes room.timeline = []; } + + // we want to set a new pagination token if this is the first time + // we've made this room or if we're nuking the timeline + var paginationToken = null; + if (joinObj.isBrandNewRoom || joinObj.timeline.limited) { + paginationToken = joinObj.timeline.prev_batch; + } + self._processRoomEvents( - room, stateEvents, timelineEvents, - joinObj.timeline ? joinObj.timeline.prev_batch : null + room, stateEvents, timelineEvents, paginationToken ); room.addEvents(ephemeralEvents); room.addEvents(accountDataEvents);