diff --git a/lib/models/event-timeline-set.js b/lib/models/event-timeline-set.js index 6b4b5be00..498b2cab7 100644 --- a/lib/models/event-timeline-set.js +++ b/lib/models/event-timeline-set.js @@ -150,6 +150,8 @@ EventTimelineSet.prototype.replaceEventId = function(oldEventId, newEventId) { * * @param {string=} backPaginationToken token for back-paginating the new timeline * @param {?bool} flush Whether to flush the non-live timelines too. + * + * @fires module:client~MatrixClient#event:"Room.timelineReset" */ EventTimelineSet.prototype.resetLiveTimeline = function(backPaginationToken, flush) { var newTimeline; @@ -180,6 +182,8 @@ EventTimelineSet.prototype.resetLiveTimeline = function(backPaginationToken, flu // stuck without realising that they *can* back-paginate. newTimeline.setPaginationToken(backPaginationToken, EventTimeline.BACKWARDS); + this.emit("Room.timelineReset", this.room, this); + 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 + */ diff --git a/lib/models/room.js b/lib/models/room.js index 1af9cd18a..1c50ad6b7 100644 --- a/lib/models/room.js +++ b/lib/models/room.js @@ -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. * *
This is used when /sync returns a 'limited' timeline. * * @param {string=} backPaginationToken token for back-paginating the new timeline - * - * @fires module:client~MatrixClient#event:"Room.timelineReset" */ Room.prototype.resetLiveTimeline = function(backPaginationToken) { for (var i = 0; i < this._timelineSets.length; i++) { @@ -210,7 +208,6 @@ Room.prototype.resetLiveTimeline = function(backPaginationToken) { } 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 timelineSet = new EventTimelineSet(this, opts); - reEmit(this, timelineSet, ["Room.timeline"]); + reEmit(this, timelineSet, ["Room.timeline", "Room.timelineReset"]); this._filteredTimelineSets[filter.filterId] = 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. *