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 {?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
*/