1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

correctly notify when timelineSets get reset

This commit is contained in:
Matthew Hodgson
2016-09-10 10:44:48 +01:00
parent b4dc5e620b
commit e614e17a71
2 changed files with 19 additions and 17 deletions

View File

@@ -150,6 +150,8 @@ EventTimelineSet.prototype.replaceEventId = function(oldEventId, newEventId) {
* *
* @param {string=} backPaginationToken token for back-paginating the new timeline * @param {string=} backPaginationToken token for back-paginating the new timeline
* @param {?bool} flush Whether to flush the non-live timelines too. * @param {?bool} flush Whether to flush the non-live timelines too.
*
* @fires module:client~MatrixClient#event:"Room.timelineReset"
*/ */
EventTimelineSet.prototype.resetLiveTimeline = function(backPaginationToken, flush) { EventTimelineSet.prototype.resetLiveTimeline = function(backPaginationToken, flush) {
var newTimeline; var newTimeline;
@@ -180,6 +182,8 @@ EventTimelineSet.prototype.resetLiveTimeline = function(backPaginationToken, flu
// stuck without realising that they *can* back-paginate. // stuck without realising that they *can* back-paginate.
newTimeline.setPaginationToken(backPaginationToken, EventTimeline.BACKWARDS); newTimeline.setPaginationToken(backPaginationToken, EventTimeline.BACKWARDS);
this.emit("Room.timelineReset", this.room, this);
this._liveTimeline = newTimeline; this._liveTimeline = newTimeline;
}; };
@@ -636,3 +640,16 @@ module.exports = EventTimelineSet;
* } * }
* }); * });
*/ */
/**
* Fires whenever the live timeline in a room is reset.
*
* When we get a 'limited' sync (for example, after a network outage), we reset
* the live timeline to be empty before adding the recent events to the new
* timeline. This event is fired after the timeline is reset, and before the
* new events are added.
*
* @event module:client~MatrixClient#"Room.timelineReset"
* @param {Room} room The room whose live timeline was reset, if any
* @param {EventTimelineSet} timelineSet timelineSet room whose live timeline was reset
*/

View File

@@ -196,13 +196,11 @@ Room.prototype.getLiveTimeline = function() {
/** /**
* Reset the live timeline, and start a new one. * Reset the live timeline of all timelineSets, and start new ones.
* *
* <p>This is used when /sync returns a 'limited' timeline. * <p>This is used when /sync returns a 'limited' timeline.
* *
* @param {string=} backPaginationToken token for back-paginating the new timeline * @param {string=} backPaginationToken token for back-paginating the new timeline
*
* @fires module:client~MatrixClient#event:"Room.timelineReset"
*/ */
Room.prototype.resetLiveTimeline = function(backPaginationToken) { Room.prototype.resetLiveTimeline = function(backPaginationToken) {
for (var i = 0; i < this._timelineSets.length; i++) { for (var i = 0; i < this._timelineSets.length; i++) {
@@ -210,7 +208,6 @@ Room.prototype.resetLiveTimeline = function(backPaginationToken) {
} }
this._fixUpLegacyTimelineFields(); this._fixUpLegacyTimelineFields();
this.emit("Room.timelineReset", this);
}; };
/** /**
@@ -464,7 +461,7 @@ Room.prototype.getOrCreateFilteredTimelineSet = function(filter) {
} }
var opts = Object.assign({ filter: filter }, this._opts); var opts = Object.assign({ filter: filter }, this._opts);
var timelineSet = new EventTimelineSet(this, opts); var timelineSet = new EventTimelineSet(this, opts);
reEmit(this, timelineSet, ["Room.timeline"]); reEmit(this, timelineSet, ["Room.timeline", "Room.timelineReset"]);
this._filteredTimelineSets[filter.filterId] = timelineSet; this._filteredTimelineSets[filter.filterId] = timelineSet;
this._timelineSets.push(timelineSet); this._timelineSets.push(timelineSet);
@@ -1321,18 +1318,6 @@ module.exports = Room;
* }); * });
*/ */
/**
* Fires whenever the live timeline in a room is reset.
*
* When we get a 'limited' sync (for example, after a network outage), we reset
* the live timeline to be empty before adding the recent events to the new
* timeline. This event is fired after the timeline is reset, and before the
* new events are added.
*
* @event module:client~MatrixClient#"Room.timelineReset"
* @param {Room} room The room whose live timeline was reset.
*/
/** /**
* Fires when the status of a transmitted event is updated. * Fires when the status of a transmitted event is updated.
* *