1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Review comments

This commit is contained in:
Kegan Dougal
2017-03-22 11:56:10 +00:00
parent 55acf21aa6
commit 1e05e0d6f8
4 changed files with 32 additions and 13 deletions

View File

@@ -63,6 +63,11 @@ function debuglog() {
* @param {SyncAccumulator=} opts.syncAccumulator An accumulator which will be
* kept up-to-date. If one is supplied, the response to getJSON() will be used
* initially.
* @param {Function=} opts.canResetEntireTimeline A function which is called
* with a room ID and returns a boolean. It should return 'true' if the SDK can
* SAFELY remove events from this room. It may not be safe to remove events if
* there are other references to the timelines for this room.
* Default: returns false.
*/
function SyncApi(client, opts) {
this.client = client;
@@ -73,6 +78,11 @@ function SyncApi(client, opts) {
opts.resolveInvitesToProfiles = opts.resolveInvitesToProfiles || false;
opts.pollTimeout = opts.pollTimeout || (30 * 1000);
opts.pendingEventOrdering = opts.pendingEventOrdering || "chronological";
if (!opts.canResetEntireTimeline) {
opts.canResetEntireTimeline = function(roomId) {
return false;
};
}
this.opts = opts;
this._peekRoomId = null;
this._currentSyncRequest = null;
@@ -848,7 +858,10 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) {
// timeline.
room.currentState.paginationToken = syncToken;
self._deregisterStateListeners(room);
room.resetLiveTimeline(joinObj.timeline.prev_batch);
room.resetLiveTimeline(
joinObj.timeline.prev_batch,
self.opts.canResetEntireTimeline(room.roomId)
);
// We have to assume any gap in any timeline is
// reason to stop incrementally tracking notifications and