You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
s/EventTimelineList/EventTimelineSet/g at vdh's req
This commit is contained in:
@@ -53,7 +53,7 @@ if (DEBUG) {
|
|||||||
* <p>In order that we can find events from their ids later, we also maintain a
|
* <p>In order that we can find events from their ids later, we also maintain a
|
||||||
* map from event_id to timeline and index.
|
* map from event_id to timeline and index.
|
||||||
*/
|
*/
|
||||||
function EventTimelineList(roomId, room, opts) {
|
function EventTimelineSet(roomId, room, opts) {
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
this.room = room;
|
this.room = room;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ function EventTimelineList(roomId, room, opts) {
|
|||||||
|
|
||||||
this._filter = opts.filter;
|
this._filter = opts.filter;
|
||||||
}
|
}
|
||||||
utils.inherits(EventTimelineList, EventEmitter);
|
utils.inherits(EventTimelineSet, EventEmitter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the filter object this timeline list is filtered on
|
* Get the filter object this timeline list is filtered on
|
||||||
@@ -88,15 +88,15 @@ EventTimeline.prototype.setFilter = function(filter) {
|
|||||||
*
|
*
|
||||||
* @return {module:models/event-timeline~EventTimeline} live timeline
|
* @return {module:models/event-timeline~EventTimeline} live timeline
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.getLiveTimeline = function(filterId) {
|
EventTimelineSet.prototype.getLiveTimeline = function(filterId) {
|
||||||
return this._liveTimeline;
|
return this._liveTimeline;
|
||||||
};
|
};
|
||||||
|
|
||||||
EventTimelineList.prototype.eventIdToTimeline = function(eventId) {
|
EventTimelineSet.prototype.eventIdToTimeline = function(eventId) {
|
||||||
return this._eventIdToTimeline[eventId];
|
return this._eventIdToTimeline[eventId];
|
||||||
};
|
};
|
||||||
|
|
||||||
EventTimelineList.prototype.replaceEventId = function(oldEventId, newEventId) {
|
EventTimelineSet.prototype.replaceEventId = function(oldEventId, newEventId) {
|
||||||
var existingTimeline = this._eventIdToTimeline[oldEventId];
|
var existingTimeline = this._eventIdToTimeline[oldEventId];
|
||||||
if (existingTimeline) {
|
if (existingTimeline) {
|
||||||
delete this._eventIdToTimeline[oldEventId];
|
delete this._eventIdToTimeline[oldEventId];
|
||||||
@@ -111,7 +111,7 @@ EventTimelineList.prototype.replaceEventId = function(oldEventId, newEventId) {
|
|||||||
*
|
*
|
||||||
* @param {string=} backPaginationToken token for back-paginating the new timeline
|
* @param {string=} backPaginationToken token for back-paginating the new timeline
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.resetLiveTimeline = function(backPaginationToken) {
|
EventTimelineSet.prototype.resetLiveTimeline = function(backPaginationToken) {
|
||||||
var newTimeline;
|
var newTimeline;
|
||||||
|
|
||||||
if (!this._timelineSupport) {
|
if (!this._timelineSupport) {
|
||||||
@@ -150,7 +150,7 @@ EventTimelineList.prototype.resetLiveTimeline = function(backPaginationToken) {
|
|||||||
* @return {?module:models/event-timeline~EventTimeline} timeline containing
|
* @return {?module:models/event-timeline~EventTimeline} timeline containing
|
||||||
* the given event, or null if unknown
|
* the given event, or null if unknown
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.getTimelineForEvent = function(eventId) {
|
EventTimelineSet.prototype.getTimelineForEvent = function(eventId) {
|
||||||
var res = this._eventIdToTimeline[eventId];
|
var res = this._eventIdToTimeline[eventId];
|
||||||
return (res === undefined) ? null : res;
|
return (res === undefined) ? null : res;
|
||||||
};
|
};
|
||||||
@@ -161,7 +161,7 @@ EventTimelineList.prototype.getTimelineForEvent = function(eventId) {
|
|||||||
* @param {string} eventId event ID to look for
|
* @param {string} eventId event ID to look for
|
||||||
* @return {?module:models/event~MatrixEvent} the given event, or undefined if unknown
|
* @return {?module:models/event~MatrixEvent} the given event, or undefined if unknown
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.findEventById = function(eventId) {
|
EventTimelineSet.prototype.findEventById = function(eventId) {
|
||||||
var tl = this.getTimelineForEvent(eventId);
|
var tl = this.getTimelineForEvent(eventId);
|
||||||
if (!tl) {
|
if (!tl) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -175,7 +175,7 @@ EventTimelineList.prototype.findEventById = function(eventId) {
|
|||||||
*
|
*
|
||||||
* @return {module:models/event-timeline~EventTimeline} newly-created timeline
|
* @return {module:models/event-timeline~EventTimeline} newly-created timeline
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.addTimeline = function() {
|
EventTimelineSet.prototype.addTimeline = function() {
|
||||||
if (!this._timelineSupport) {
|
if (!this._timelineSupport) {
|
||||||
throw new Error("timeline support is disabled. Set the 'timelineSupport'" +
|
throw new Error("timeline support is disabled. Set the 'timelineSupport'" +
|
||||||
" parameter to true when creating MatrixClient to enable" +
|
" parameter to true when creating MatrixClient to enable" +
|
||||||
@@ -207,18 +207,18 @@ EventTimelineList.prototype.addTimeline = function() {
|
|||||||
* @fires module:client~MatrixClient#event:"Room.timeline"
|
* @fires module:client~MatrixClient#event:"Room.timeline"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
||||||
timeline, paginationToken) {
|
timeline, paginationToken) {
|
||||||
if (!timeline) {
|
if (!timeline) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"'timeline' not specified for EventTimelineList.addEventsToTimeline"
|
"'timeline' not specified for EventTimelineSet.addEventsToTimeline"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 " +
|
"Room.addEventsToTimeline cannot be used for adding events to " +
|
||||||
"the live timeline - use EventTimelineList.addLiveEvents instead"
|
"the live timeline - use EventTimelineSet.addLiveEvents instead"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ EventTimelineList.prototype.addEventsToTimeline = function(events, toStartOfTime
|
|||||||
/**
|
/**
|
||||||
* Add event to the live timeline
|
* Add event to the live timeline
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
EventTimelineSet.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
||||||
if (this._filter) {
|
if (this._filter) {
|
||||||
var events = this._filter.filterRoomTimeline([event]);
|
var events = this._filter.filterRoomTimeline([event]);
|
||||||
if (!events) return;
|
if (!events) return;
|
||||||
@@ -376,7 +376,7 @@ EventTimelineList.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
|||||||
var timeline = this._eventIdToTimeline[event.getId()];
|
var timeline = this._eventIdToTimeline[event.getId()];
|
||||||
if (timeline) {
|
if (timeline) {
|
||||||
if (duplicateStrategy === "replace") {
|
if (duplicateStrategy === "replace") {
|
||||||
debuglog("EventTimelineList.addLiveEvent: replacing duplicate event " +
|
debuglog("EventTimelineSet.addLiveEvent: replacing duplicate event " +
|
||||||
event.getId());
|
event.getId());
|
||||||
var tlEvents = timeline.getEvents();
|
var tlEvents = timeline.getEvents();
|
||||||
for (var j = 0; j < tlEvents.length; j++) {
|
for (var j = 0; j < tlEvents.length; j++) {
|
||||||
@@ -397,7 +397,7 @@ EventTimelineList.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debuglog("EventTimelineList.addLiveEvent: ignoring duplicate event " +
|
debuglog("EventTimelineSet.addLiveEvent: ignoring duplicate event " +
|
||||||
event.getId());
|
event.getId());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -420,7 +420,7 @@ EventTimelineList.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.addEventToTimeline = function(event, timeline, toStartOfTimeline) {
|
EventTimelineSet.prototype.addEventToTimeline = function(event, timeline, toStartOfTimeline) {
|
||||||
var eventId = event.getId();
|
var eventId = event.getId();
|
||||||
timeline.addEvent(event, toStartOfTimeline);
|
timeline.addEvent(event, toStartOfTimeline);
|
||||||
this._eventIdToTimeline[eventId] = timeline;
|
this._eventIdToTimeline[eventId] = timeline;
|
||||||
@@ -433,7 +433,7 @@ EventTimelineList.prototype.addEventToTimeline = function(event, timeline, toSta
|
|||||||
this.emit("Room.timeline", event, this.room, Boolean(toStartOfTimeline), false, data);
|
this.emit("Room.timeline", event, this.room, Boolean(toStartOfTimeline), false, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
EventTimelineList.prototype.replaceOrAddEvent = function(localEvent, oldEventId, newEventId) {
|
EventTimelineSet.prototype.replaceOrAddEvent = function(localEvent, oldEventId, newEventId) {
|
||||||
var existingTimeline = this._eventIdToTimeline[oldEventId];
|
var existingTimeline = this._eventIdToTimeline[oldEventId];
|
||||||
if (existingTimeline) {
|
if (existingTimeline) {
|
||||||
delete this._eventIdToTimeline[oldEventId];
|
delete this._eventIdToTimeline[oldEventId];
|
||||||
@@ -451,7 +451,7 @@ EventTimelineList.prototype.replaceOrAddEvent = function(localEvent, oldEventId,
|
|||||||
* @return {?MatrixEvent} the removed event, or null if the event was not found
|
* @return {?MatrixEvent} the removed event, or null if the event was not found
|
||||||
* in this room.
|
* in this room.
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.removeEvent = function(eventId) {
|
EventTimelineSet.prototype.removeEvent = function(eventId) {
|
||||||
var timeline = this._eventIdToTimeline[eventId];
|
var timeline = this._eventIdToTimeline[eventId];
|
||||||
if (!timeline) {
|
if (!timeline) {
|
||||||
return null;
|
return null;
|
||||||
@@ -481,7 +481,7 @@ EventTimelineList.prototype.removeEvent = function(eventId) {
|
|||||||
* of the events, or because they are in separate timelines which don't join
|
* of the events, or because they are in separate timelines which don't join
|
||||||
* up).
|
* up).
|
||||||
*/
|
*/
|
||||||
EventTimelineList.prototype.compareEventOrdering = function(eventId1, eventId2) {
|
EventTimelineSet.prototype.compareEventOrdering = function(eventId1, eventId2) {
|
||||||
if (eventId1 == eventId2) {
|
if (eventId1 == eventId2) {
|
||||||
// optimise this case
|
// optimise this case
|
||||||
return 0;
|
return 0;
|
||||||
@@ -543,9 +543,9 @@ EventTimelineList.prototype.compareEventOrdering = function(eventId1, eventId2)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The EventTimelineList class.
|
* The EventTimelineSet class.
|
||||||
*/
|
*/
|
||||||
module.exports = EventTimelineList;
|
module.exports = EventTimelineSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires whenever the timeline in a room is updated.
|
* Fires whenever the timeline in a room is updated.
|
||||||
@@ -565,7 +565,8 @@ module.exports = EventTimelineList;
|
|||||||
* added to the end of the live timeline
|
* added to the end of the live timeline
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* matrixClient.on("Room.timeline", function(event, room, toStartOfTimeline, data){
|
* matrixClient.on("Room.timeline",
|
||||||
|
* function(event, room, toStartOfTimeline, removed, data) {
|
||||||
* if (!toStartOfTimeline && data.liveEvent) {
|
* if (!toStartOfTimeline && data.liveEvent) {
|
||||||
* var messageToAppend = room.timeline.[room.timeline.length - 1];
|
* var messageToAppend = room.timeline.[room.timeline.length - 1];
|
||||||
* }
|
* }
|
||||||
@@ -583,3 +584,4 @@ module.exports = EventTimelineList;
|
|||||||
* @event module:client~MatrixClient#"Room.timelineReset"
|
* @event module:client~MatrixClient#"Room.timelineReset"
|
||||||
* @param {Room} room The room whose live timeline was reset.
|
* @param {Room} room The room whose live timeline was reset.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ var MatrixEvent = require("./event").MatrixEvent;
|
|||||||
var utils = require("../utils");
|
var utils = require("../utils");
|
||||||
var ContentRepo = require("../content-repo");
|
var ContentRepo = require("../content-repo");
|
||||||
var EventTimeline = require("./event-timeline");
|
var EventTimeline = require("./event-timeline");
|
||||||
var EventTimelineList = require("./event-timeline-list");
|
var EventTimelineSet = require("./event-timeline-set");
|
||||||
|
|
||||||
|
|
||||||
// var DEBUG = false;
|
// var DEBUG = false;
|
||||||
@@ -162,18 +162,18 @@ function Room(roomId, opts) {
|
|||||||
|
|
||||||
// all our per-room timeline lists. the first one is the unfiltered ones;
|
// all our per-room timeline lists. the first one is the unfiltered ones;
|
||||||
// the subsequent ones are the filtered ones in no particular order.
|
// the subsequent ones are the filtered ones in no particular order.
|
||||||
this._timelineLists = [ new EventTimelineList(roomId, this, opts) ];
|
this._timelineSets = [ new EventTimelineSet(roomId, this, opts) ];
|
||||||
reEmit(this, this._timelineLists[0], [ "Room.timeline" ]);
|
reEmit(this, this._timelineSets[0], [ "Room.timeline" ]);
|
||||||
|
|
||||||
this._fixUpLegacyTimelineFields();
|
this._fixUpLegacyTimelineFields();
|
||||||
|
|
||||||
// any filtered timeline lists we're maintaining for this room
|
// any filtered timeline lists we're maintaining for this room
|
||||||
this._filteredTimelineLists = {
|
this._filteredTimelineSets = {
|
||||||
// filter_id: timelineList
|
// filter_id: timelineSet
|
||||||
};
|
};
|
||||||
|
|
||||||
// a reference to our shared notification timeline list
|
// a reference to our shared notification timeline list
|
||||||
this._notifTimelineList = opts.notifTimelineList;
|
this._notifTimelineSet = opts.notifTimelineSet;
|
||||||
|
|
||||||
if (this._opts.pendingEventOrdering == "detached") {
|
if (this._opts.pendingEventOrdering == "detached") {
|
||||||
this._pendingEventList = [];
|
this._pendingEventList = [];
|
||||||
@@ -205,7 +205,7 @@ Room.prototype.getPendingEvents = function() {
|
|||||||
* @return {module:models/event-timeline~EventTimeline} live timeline
|
* @return {module:models/event-timeline~EventTimeline} live timeline
|
||||||
*/
|
*/
|
||||||
Room.prototype.getLiveTimeline = function(filterId) {
|
Room.prototype.getLiveTimeline = function(filterId) {
|
||||||
return this._timelineLists[0].getLiveTimeline();
|
return this._timelineSets[0].getLiveTimeline();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -221,8 +221,8 @@ Room.prototype.getLiveTimeline = function(filterId) {
|
|||||||
Room.prototype.resetLiveTimeline = function(backPaginationToken) {
|
Room.prototype.resetLiveTimeline = function(backPaginationToken) {
|
||||||
var newTimeline;
|
var newTimeline;
|
||||||
|
|
||||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||||
this._timelineLists[i].resetLiveTimeline(backPaginationToken);
|
this._timelineSets[i].resetLiveTimeline(backPaginationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._fixUpLegacyTimelineFields();
|
this._fixUpLegacyTimelineFields();
|
||||||
@@ -239,9 +239,9 @@ Room.prototype._fixUpLegacyTimelineFields = function() {
|
|||||||
// and this.oldState and this.currentState as references to the
|
// and this.oldState and this.currentState as references to the
|
||||||
// state at the start and end of that timeline. These are more
|
// state at the start and end of that timeline. These are more
|
||||||
// for backwards-compatibility than anything else.
|
// for backwards-compatibility than anything else.
|
||||||
this.timeline = this._timelineLists[0].getLiveTimeline().getEvents();
|
this.timeline = this._timelineSets[0].getLiveTimeline().getEvents();
|
||||||
this.oldState = this._timelineLists[0].getLiveTimeline().getState(EventTimeline.BACKWARDS);
|
this.oldState = this._timelineSets[0].getLiveTimeline().getState(EventTimeline.BACKWARDS);
|
||||||
this.currentState = this._timelineLists[0].getLiveTimeline().getState(EventTimeline.FORWARDS);
|
this.currentState = this._timelineSets[0].getLiveTimeline().getState(EventTimeline.FORWARDS);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,7 +253,7 @@ Room.prototype._fixUpLegacyTimelineFields = function() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Room.prototype.getTimelineForEvent = function(eventId) {
|
Room.prototype.getTimelineForEvent = function(eventId) {
|
||||||
return this._timelineLists[0].getTimelineForEvent(eventId);
|
return this._timelineSets[0].getTimelineForEvent(eventId);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -262,7 +262,7 @@ Room.prototype.getTimelineForEvent = function(eventId) {
|
|||||||
* @return {module:models/event-timeline~EventTimeline} newly-created timeline
|
* @return {module:models/event-timeline~EventTimeline} newly-created timeline
|
||||||
*/
|
*/
|
||||||
Room.prototype.addTimeline = function() {
|
Room.prototype.addTimeline = function() {
|
||||||
return this._timelineLists[0].addTimeline();
|
return this._timelineSets[0].addTimeline();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -272,7 +272,7 @@ Room.prototype.addTimeline = function() {
|
|||||||
* @return {?module:models/event.MatrixEvent} the given event, or undefined if unknown
|
* @return {?module:models/event.MatrixEvent} the given event, or undefined if unknown
|
||||||
*/
|
*/
|
||||||
Room.prototype.findEventById = function(eventId) {
|
Room.prototype.findEventById = function(eventId) {
|
||||||
return this._timelineLists[0].findEventById(eventId);
|
return this._timelineSets[0].findEventById(eventId);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -388,8 +388,8 @@ Room.prototype.getCanonicalAlias = function() {
|
|||||||
*/
|
*/
|
||||||
Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
||||||
timeline, paginationToken) {
|
timeline, paginationToken) {
|
||||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||||
this._timelineLists[0].addEventsToTimeline(
|
this._timelineSets[0].addEventsToTimeline(
|
||||||
events, toStartOfTimeline,
|
events, toStartOfTimeline,
|
||||||
timeline, paginationToken
|
timeline, paginationToken
|
||||||
);
|
);
|
||||||
@@ -455,28 +455,28 @@ Room.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a timelineList for this room with the given filter
|
* Add a timelineSet for this room with the given filter
|
||||||
*/
|
*/
|
||||||
Room.prototype.addFilteredTimelineList = function(filter) {
|
Room.prototype.addFilteredTimelineSet = function(filter) {
|
||||||
var timelineList = new EventTimelineList(
|
var timelineSet = new EventTimelineSet(
|
||||||
this.roomId, this, {
|
this.roomId, this, {
|
||||||
filter: filter,
|
filter: filter,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
reEmit(this, timelineList, [ "Room.timeline" ]);
|
reEmit(this, timelineSet, [ "Room.timeline" ]);
|
||||||
this._filteredTimelineLists[filter.filterId] = timelineList;
|
this._filteredTimelineSets[filter.filterId] = timelineSet;
|
||||||
this._timelineLists.push(timelineList);
|
this._timelineSets.push(timelineSet);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forget the timelineList for this room with the given filter
|
* Forget the timelineSet for this room with the given filter
|
||||||
*/
|
*/
|
||||||
Room.prototype.removeFilteredTimelineList = function(filter) {
|
Room.prototype.removeFilteredTimelineSet = function(filter) {
|
||||||
var timelineList = this._filteredTimelineLists[filter.filterId];
|
var timelineSet = this._filteredTimelineSets[filter.filterId];
|
||||||
delete this._filteredTimelineLists[filter.filterId];
|
delete this._filteredTimelineSets[filter.filterId];
|
||||||
var i = this._timelineLists.indexOf(timelineList);
|
var i = this._timelineSets.indexOf(timelineSet);
|
||||||
if (i > -1) {
|
if (i > -1) {
|
||||||
this._timelineLists.splice(i, 1);
|
this._timelineSets.splice(i, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -493,14 +493,14 @@ Room.prototype._addLiveEvent = function(event, duplicateStrategy) {
|
|||||||
if (event.getType() === "m.room.redaction") {
|
if (event.getType() === "m.room.redaction") {
|
||||||
var redactId = event.event.redacts;
|
var redactId = event.event.redacts;
|
||||||
|
|
||||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||||
var timelineList = this._timelineLists[i];
|
var timelineSet = this._timelineSets[i];
|
||||||
// if we know about this event, redact its contents now.
|
// if we know about this event, redact its contents now.
|
||||||
var redactedEvent = timelineList.findEventById(redactId);
|
var redactedEvent = timelineSet.findEventById(redactId);
|
||||||
if (redactedEvent) {
|
if (redactedEvent) {
|
||||||
redactedEvent.makeRedacted(event);
|
redactedEvent.makeRedacted(event);
|
||||||
// FIXME: these should be emitted from EventTimelineList probably
|
// FIXME: these should be emitted from EventTimelineSet probably
|
||||||
this.emit("Room.redaction", event, this, timelineList);
|
this.emit("Room.redaction", event, this, timelineSet);
|
||||||
|
|
||||||
// TODO: we stash user displaynames (among other things) in
|
// TODO: we stash user displaynames (among other things) in
|
||||||
// RoomMember objects which are then attached to other events
|
// RoomMember objects which are then attached to other events
|
||||||
@@ -527,14 +527,14 @@ Room.prototype._addLiveEvent = function(event, duplicateStrategy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add to our timeline lists
|
// add to our timeline lists
|
||||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||||
this._timelineLists[i].addLiveEvent(event, duplicateStrategy);
|
this._timelineSets[i].addLiveEvent(event, duplicateStrategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to notification timeline list, if any
|
// add to notification timeline list, if any
|
||||||
if (this._notifTimelineList) {
|
if (this._notifTimelineSet) {
|
||||||
if (event.isNotification()) {
|
if (event.isNotification()) {
|
||||||
this._notifTimelineList.addLiveEvent(event, duplicateStrategy);
|
this._notifTimelineSet.addLiveEvent(event, duplicateStrategy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,11 +585,11 @@ Room.prototype.addPendingEvent = function(event, txnId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// call setEventMetadata to set up event.sender etc
|
// call setEventMetadata to set up event.sender etc
|
||||||
// as event is shared over all timelinelists, we set up its metadata based
|
// as event is shared over all timelineSets, we set up its metadata based
|
||||||
// on the unfiltered timelineList.
|
// on the unfiltered timelineSet.
|
||||||
EventTimeline.setEventMetadata(
|
EventTimeline.setEventMetadata(
|
||||||
event,
|
event,
|
||||||
this._timelineLists[0].getLiveTimeline().getState(EventTimeline.FORWARDS),
|
this._timelineSets[0].getLiveTimeline().getState(EventTimeline.FORWARDS),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -598,10 +598,10 @@ Room.prototype.addPendingEvent = function(event, txnId) {
|
|||||||
if (this._opts.pendingEventOrdering == "detached") {
|
if (this._opts.pendingEventOrdering == "detached") {
|
||||||
this._pendingEventList.push(event);
|
this._pendingEventList.push(event);
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||||
this._timelineLists[i].addEventToTimeline(event, this._timelineLists[i].getLiveTimeline(), false);
|
this._timelineSets[i].addEventToTimeline(event, this._timelineSets[i].getLiveTimeline(), false);
|
||||||
}
|
}
|
||||||
// notifications are receive-only, so we don't need to worry about this._notifTimelineList.
|
// notifications are receive-only, so we don't need to worry about this._notifTimelineSet.
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit("Room.localEchoUpdated", event, this, null, null);
|
this.emit("Room.localEchoUpdated", event, this, null, null);
|
||||||
@@ -645,11 +645,11 @@ Room.prototype._handleRemoteEcho = function(remoteEvent, localEvent) {
|
|||||||
// successfully sent.
|
// successfully sent.
|
||||||
localEvent.status = null;
|
localEvent.status = null;
|
||||||
|
|
||||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||||
var timelineList = this._timelineLists[i];
|
var timelineSet = this._timelineSets[i];
|
||||||
|
|
||||||
// if it's already in the timeline, update the timeline map. If it's not, add it.
|
// if it's already in the timeline, update the timeline map. If it's not, add it.
|
||||||
timelineList.replaceOrAddEvent(localEvent, oldEventId, newEventId);
|
timelineSet.replaceOrAddEvent(localEvent, oldEventId, newEventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit("Room.localEchoUpdated", localEvent, this,
|
this.emit("Room.localEchoUpdated", localEvent, this,
|
||||||
@@ -705,7 +705,7 @@ Room.prototype.updatePendingEvent = function(event, newStatus, newEventId) {
|
|||||||
|
|
||||||
// SENT races against /sync, so we have to special-case it.
|
// SENT races against /sync, so we have to special-case it.
|
||||||
if (newStatus == EventStatus.SENT) {
|
if (newStatus == EventStatus.SENT) {
|
||||||
var timeline = this._timelineLists[0].eventIdToTimeline(newEventId);
|
var timeline = this._timelineSets[0].eventIdToTimeline(newEventId);
|
||||||
if (timeline) {
|
if (timeline) {
|
||||||
// we've already received the event via the event stream.
|
// we've already received the event via the event stream.
|
||||||
// nothing more to do here.
|
// nothing more to do here.
|
||||||
@@ -736,8 +736,8 @@ Room.prototype.updatePendingEvent = function(event, newStatus, newEventId) {
|
|||||||
// if the event was already in the timeline (which will be the case if
|
// if the event was already in the timeline (which will be the case if
|
||||||
// opts.pendingEventOrdering==chronological), we need to update the
|
// opts.pendingEventOrdering==chronological), we need to update the
|
||||||
// timeline map.
|
// timeline map.
|
||||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||||
this._timelineLists[i].replaceEventId(oldEventId, newEventId);
|
this._timelineSets[i].replaceEventId(oldEventId, newEventId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (newStatus == EventStatus.CANCELLED) {
|
else if (newStatus == EventStatus.CANCELLED) {
|
||||||
@@ -778,12 +778,12 @@ Room.prototype.addLiveEvents = function(events, duplicateStrategy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sanity check that the live timeline is still live
|
// sanity check that the live timeline is still live
|
||||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||||
var liveTimeline = this._timelineLists[i].getLiveTimeline();
|
var liveTimeline = this._timelineSets[i].getLiveTimeline();
|
||||||
if (liveTimeline.getPaginationToken(EventTimeline.FORWARDS)) {
|
if (liveTimeline.getPaginationToken(EventTimeline.FORWARDS)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"live timeline "+i+" is no longer live - it has a pagination token (" +
|
"live timeline "+i+" is no longer live - it has a pagination token (" +
|
||||||
timelineList.getPaginationToken(EventTimeline.FORWARDS) + ")"
|
timelineSet.getPaginationToken(EventTimeline.FORWARDS) + ")"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (liveTimeline.getNeighbouringTimeline(EventTimeline.FORWARDS)) {
|
if (liveTimeline.getNeighbouringTimeline(EventTimeline.FORWARDS)) {
|
||||||
@@ -830,8 +830,8 @@ Room.prototype.removeEvents = function(event_ids) {
|
|||||||
*/
|
*/
|
||||||
Room.prototype.removeEvent = function(eventId) {
|
Room.prototype.removeEvent = function(eventId) {
|
||||||
var removedAny;
|
var removedAny;
|
||||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||||
var removed = this._timelineLists[i].removeEvent(eventId);
|
var removed = this._timelineSets[i].removeEvent(eventId);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
removedAny = true;
|
removedAny = true;
|
||||||
}
|
}
|
||||||
@@ -992,7 +992,7 @@ Room.prototype._addReceiptsToStructure = function(event, receipts) {
|
|||||||
// than the one we already have. (This is managed
|
// than the one we already have. (This is managed
|
||||||
// server-side, but because we synthesize RRs locally we
|
// server-side, but because we synthesize RRs locally we
|
||||||
// have to do it here too.)
|
// have to do it here too.)
|
||||||
var ordering = self._timelineLists[0].compareEventOrdering(
|
var ordering = self._timelineSets[0].compareEventOrdering(
|
||||||
existingReceipt.eventId, eventId);
|
existingReceipt.eventId, eventId);
|
||||||
if (ordering !== null && ordering >= 0) {
|
if (ordering !== null && ordering >= 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -479,13 +479,13 @@ describe("Room", function() {
|
|||||||
it("should handle events in the same timeline", function() {
|
it("should handle events in the same timeline", function() {
|
||||||
room.addLiveEvents(events);
|
room.addLiveEvents(events);
|
||||||
|
|
||||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(),
|
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(),
|
||||||
events[1].getId()))
|
events[1].getId()))
|
||||||
.toBeLessThan(0);
|
.toBeLessThan(0);
|
||||||
expect(room._timelineLists[0].compareEventOrdering(events[2].getId(),
|
expect(room._timelineSets[0].compareEventOrdering(events[2].getId(),
|
||||||
events[1].getId()))
|
events[1].getId()))
|
||||||
.toBeGreaterThan(0);
|
.toBeGreaterThan(0);
|
||||||
expect(room._timelineLists[0].compareEventOrdering(events[1].getId(),
|
expect(room._timelineSets[0].compareEventOrdering(events[1].getId(),
|
||||||
events[1].getId()))
|
events[1].getId()))
|
||||||
.toEqual(0);
|
.toEqual(0);
|
||||||
});
|
});
|
||||||
@@ -498,10 +498,10 @@ describe("Room", function() {
|
|||||||
room.addEventsToTimeline([events[0]], false, oldTimeline);
|
room.addEventsToTimeline([events[0]], false, oldTimeline);
|
||||||
room.addLiveEvents([events[1]]);
|
room.addLiveEvents([events[1]]);
|
||||||
|
|
||||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(),
|
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(),
|
||||||
events[1].getId()))
|
events[1].getId()))
|
||||||
.toBeLessThan(0);
|
.toBeLessThan(0);
|
||||||
expect(room._timelineLists[0].compareEventOrdering(events[1].getId(),
|
expect(room._timelineSets[0].compareEventOrdering(events[1].getId(),
|
||||||
events[0].getId()))
|
events[0].getId()))
|
||||||
.toBeGreaterThan(0);
|
.toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
@@ -512,10 +512,10 @@ describe("Room", function() {
|
|||||||
room.addEventsToTimeline([events[0]], false, oldTimeline);
|
room.addEventsToTimeline([events[0]], false, oldTimeline);
|
||||||
room.addLiveEvents([events[1]]);
|
room.addLiveEvents([events[1]]);
|
||||||
|
|
||||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(),
|
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(),
|
||||||
events[1].getId()))
|
events[1].getId()))
|
||||||
.toBe(null);
|
.toBe(null);
|
||||||
expect(room._timelineLists[0].compareEventOrdering(events[1].getId(),
|
expect(room._timelineSets[0].compareEventOrdering(events[1].getId(),
|
||||||
events[0].getId()))
|
events[0].getId()))
|
||||||
.toBe(null);
|
.toBe(null);
|
||||||
});
|
});
|
||||||
@@ -523,11 +523,11 @@ describe("Room", function() {
|
|||||||
it("should return null for unknown events", function() {
|
it("should return null for unknown events", function() {
|
||||||
room.addLiveEvents(events);
|
room.addLiveEvents(events);
|
||||||
|
|
||||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(), "xxx"))
|
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(), "xxx"))
|
||||||
.toBe(null);
|
.toBe(null);
|
||||||
expect(room._timelineLists[0].compareEventOrdering("xxx", events[0].getId()))
|
expect(room._timelineSets[0].compareEventOrdering("xxx", events[0].getId()))
|
||||||
.toBe(null);
|
.toBe(null);
|
||||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(),
|
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(),
|
||||||
events[0].getId()))
|
events[0].getId()))
|
||||||
.toBe(0);
|
.toBe(0);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user