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

fix filtering

This commit is contained in:
Matthew Hodgson
2016-09-07 02:17:03 +01:00
parent 1bda527e3d
commit c4995bd153
3 changed files with 53 additions and 26 deletions

View File

@@ -464,11 +464,8 @@ Room.prototype.getOrCreateFilteredTimelineSet = function(filter) {
if (this._filteredTimelineSets[filter.filterId]) {
return this._filteredTimelineSets[filter.filterId];
}
var timelineSet = new EventTimelineSet(
this.roomId, this, {
filter: filter,
}
);
var opts = Object.assign({ filter: filter }, this._opts);
var timelineSet = new EventTimelineSet(this.roomId, this, opts);
reEmit(this, timelineSet, [ "Room.timeline" ]);
this._filteredTimelineSets[filter.filterId] = timelineSet;
this._timelineSets.push(timelineSet);
@@ -607,7 +604,15 @@ Room.prototype.addPendingEvent = function(event, txnId) {
this._pendingEventList.push(event);
} else {
for (var i = 0; i < this._timelineSets.length; i++) {
this._timelineSets[i].addEventToTimeline(event, this._timelineSets[i].getLiveTimeline(), false);
var timelineSet = this._timelineSets[i];
if (timelineSet.getFilter()) {
if (this._filter.filterRoomTimeline([event]).length) {
timelineSet.addEventToTimeline(event, timelineSet.getLiveTimeline(), false);
}
}
else {
timelineSet.addEventToTimeline(event, timelineSet.getLiveTimeline(), false);
}
}
// notifications are receive-only, so we don't need to worry about this._notifTimelineSet.
}