You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +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:
12
lib/sync.js
12
lib/sync.js
@@ -361,10 +361,12 @@ SyncApi.prototype._sync = function(syncOptions, attempt) {
|
|||||||
filterId = this._getGuestFilter();
|
filterId = this._getGuestFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var syncToken = client.store.getSyncToken();
|
||||||
|
|
||||||
var qps = {
|
var qps = {
|
||||||
filter: filterId,
|
filter: filterId,
|
||||||
timeout: this.opts.pollTimeout,
|
timeout: this.opts.pollTimeout,
|
||||||
since: client.store.getSyncToken() || undefined // do not send 'null'
|
since: syncToken || undefined // do not send 'null'
|
||||||
};
|
};
|
||||||
|
|
||||||
if (attempt > 1) {
|
if (attempt > 1) {
|
||||||
@@ -557,6 +559,11 @@ SyncApi.prototype._processSyncResponse = function(data) {
|
|||||||
|
|
||||||
if (joinObj.timeline.limited) {
|
if (joinObj.timeline.limited) {
|
||||||
// nuke the timeline so we don't get holes
|
// 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);
|
self._deregisterStateListeners(room);
|
||||||
room.resetLiveTimeline();
|
room.resetLiveTimeline();
|
||||||
self._registerStateListeners(room);
|
self._registerStateListeners(room);
|
||||||
@@ -727,7 +734,8 @@ SyncApi.prototype._resolveInvites = function(room) {
|
|||||||
* at the *START* of the timeline list if it is supplied.
|
* at the *START* of the timeline list if it is supplied.
|
||||||
* @param {?MatrixEvent[]} timelineEventList A list of timeline events. Lower index
|
* @param {?MatrixEvent[]} timelineEventList A list of timeline events. Lower index
|
||||||
* is earlier in time. Higher index is later.
|
* 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,
|
SyncApi.prototype._processRoomEvents = function(room, stateEventList,
|
||||||
timelineEventList, paginationToken) {
|
timelineEventList, paginationToken) {
|
||||||
|
|||||||
Reference in New Issue
Block a user