You've already forked matrix-js-sdk
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:
@@ -237,8 +237,8 @@ EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimel
|
|||||||
|
|
||||||
if (!toStartOfTimeline && timeline == this._liveTimeline) {
|
if (!toStartOfTimeline && timeline == this._liveTimeline) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Room.addEventsToTimeline cannot be used for adding events to " +
|
"EventTimelineSet.addEventsToTimeline cannot be used for adding events to " +
|
||||||
"the live timeline - use EventTimelineSet.addLiveEvents instead"
|
"the live timeline - use Room.addLiveEvents instead"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -469,6 +469,33 @@ Room.prototype.getOrCreateFilteredTimelineSet = function(filter) {
|
|||||||
reEmit(this, timelineSet, [ "Room.timeline" ]);
|
reEmit(this, timelineSet, [ "Room.timeline" ]);
|
||||||
this._filteredTimelineSets[filter.filterId] = timelineSet;
|
this._filteredTimelineSets[filter.filterId] = timelineSet;
|
||||||
this._timelineSets.push(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;
|
return timelineSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user