From 39dc6a174206eab20b48392900cd2ed070634425 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 28 Aug 2019 16:34:09 -0400 Subject: [PATCH] Fix addPendingEvent with pending event order == chronological When the pending event order setting was set to 'chronological' (the default) `addPendingEvent` would NPE because Room no longer has a `this._filter` property. It should get the filter from the event timeline set instead, as it does in the previous line when checking or the presence of a filter. We should strongly consider changing the default pending event order to 'detached' and probably removing 'chronological' or comitting to support it properly: it's not really tested and is prone to breakage like this. Applies flumpt's fix from https://github.com/matrix-org/matrix-js-sdk/issues/599 Fixes https://github.com/matrix-org/matrix-js-sdk/issues/599 --- src/models/room.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/room.js b/src/models/room.js index 625dc0f0a6f..453546f0f2d 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -1187,7 +1187,7 @@ Room.prototype.addPendingEvent = function(event, txnId) { for (let i = 0; i < this._timelineSets.length; i++) { const timelineSet = this._timelineSets[i]; if (timelineSet.getFilter()) { - if (this._filter.filterRoomTimeline([event]).length) { + if (timelineSet.getFilter().filterRoomTimeline([event]).length) { timelineSet.addEventToTimeline(event, timelineSet.getLiveTimeline(), false); } @@ -1216,7 +1216,7 @@ Room.prototype._aggregateNonLiveRelation = function(event) { for (let i = 0; i < this._timelineSets.length; i++) { const timelineSet = this._timelineSets[i]; if (timelineSet.getFilter()) { - if (this._filter.filterRoomTimeline([event]).length) { + if (timelineSet.getFilter().filterRoomTimeline([event]).length) { timelineSet.aggregateRelations(event); } } else {