1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

populate up filtered timelineSets vaguely correctly

This commit is contained in:
Matthew Hodgson
2016-09-07 19:45:30 +01:00
parent c4995bd153
commit 5e583d3c50
2 changed files with 29 additions and 2 deletions

View File

@@ -237,8 +237,8 @@ EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimel
if (!toStartOfTimeline && timeline == this._liveTimeline) {
throw new Error(
"Room.addEventsToTimeline cannot be used for adding events to " +
"the live timeline - use EventTimelineSet.addLiveEvents instead"
"EventTimelineSet.addEventsToTimeline cannot be used for adding events to " +
"the live timeline - use Room.addLiveEvents instead"
);
}

View File

@@ -469,6 +469,33 @@ Room.prototype.getOrCreateFilteredTimelineSet = function(filter) {
reEmit(this, timelineSet, [ "Room.timeline" ]);
this._filteredTimelineSets[filter.filterId] = timelineSet;
this._timelineSets.push(timelineSet);
// populate up the new timelineSet with filtered events from our live
// unfiltered timeline.
//
// XXX: This is risky as our timeline
// may have grown huge and so take a long time to filter.
// see https://github.com/vector-im/vector-web/issues/2109
var unfilteredLiveTimeline = this._timelineSets[0].getLiveTimeline();
unfilteredLiveTimeline.getEvents().forEach(function(event) {
timelineSet.addLiveEvent(event);
});
timelineSet.getLiveTimeline().setPaginationToken(
unfilteredLiveTimeline.getPaginationToken(EventTimeline.BACKWARDS),
EventTimeline.BACKWARDS
);
// alternatively, we could try to do something like this to try and re-paginate
// in the filtered events from nothing, but Mark says it's an abuse of the API
// to do so:
//
// timelineSet.resetLiveTimeline(
// unfilteredLiveTimeline.getPaginationToken(EventTimeline.FORWARDS)
// );
return timelineSet;
};