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

WIP filtered timelines

This commit is contained in:
Matthew Hodgson
2016-08-23 14:31:47 +01:00
parent 6432a64442
commit dd5878015a
3 changed files with 209 additions and 0 deletions

View File

@@ -36,6 +36,7 @@ function EventTimeline(roomId) {
this._startState.paginationToken = null;
this._endState = new RoomState(roomId);
this._endState.paginationToken = null;
this._filter = null;
this._prevTimeline = null;
this._nextTimeline = null;
@@ -58,6 +59,21 @@ EventTimeline.BACKWARDS = "b";
*/
EventTimeline.FORWARDS = "f";
/**
* Get the filter object this timeline is filtered on
*/
EventTimeline.prototype.getFilter = function() {
return this._filter;
}
/**
* Set the filter object this timeline is filtered on
* (passed to the server when paginating via /messages).
*/
EventTimeline.prototype.setFilter = function(filter) {
this._filter = filter;
}
/**
* Initialise the start and end state with the given events
*
@@ -217,6 +233,14 @@ EventTimeline.prototype.setNeighbouringTimeline = function(neighbour, direction)
EventTimeline.prototype.addEvent = function(event, atStart) {
var stateContext = atStart ? this._startState : this._endState;
// manually filter the event if we have a filter, as currently we insert
// events incrementally only from the main /sync rather than a filtered
// /sync to avoid running multiple redundant /syncs.
if (this._filter) {
var events = this._filter.filterRoomTimeline([event]);
if (!events) return;
}
setEventMetadata(event, stateContext, atStart);
// modify state