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