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
|
||||
* map from event_id to timeline and index.
|
||||
*/
|
||||
function EventTimelineList(roomId, room, opts) {
|
||||
function EventTimelineSet(roomId, room, opts) {
|
||||
this.roomId = roomId;
|
||||
this.room = room;
|
||||
|
||||
@@ -66,7 +66,7 @@ function EventTimelineList(roomId, room, opts) {
|
||||
|
||||
this._filter = opts.filter;
|
||||
}
|
||||
utils.inherits(EventTimelineList, EventEmitter);
|
||||
utils.inherits(EventTimelineSet, EventEmitter);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
EventTimelineList.prototype.getLiveTimeline = function(filterId) {
|
||||
EventTimelineSet.prototype.getLiveTimeline = function(filterId) {
|
||||
return this._liveTimeline;
|
||||
};
|
||||
|
||||
EventTimelineList.prototype.eventIdToTimeline = function(eventId) {
|
||||
EventTimelineSet.prototype.eventIdToTimeline = function(eventId) {
|
||||
return this._eventIdToTimeline[eventId];
|
||||
};
|
||||
|
||||
EventTimelineList.prototype.replaceEventId = function(oldEventId, newEventId) {
|
||||
EventTimelineSet.prototype.replaceEventId = function(oldEventId, newEventId) {
|
||||
var existingTimeline = this._eventIdToTimeline[oldEventId];
|
||||
if (existingTimeline) {
|
||||
delete this._eventIdToTimeline[oldEventId];
|
||||
@@ -111,7 +111,7 @@ EventTimelineList.prototype.replaceEventId = function(oldEventId, newEventId) {
|
||||
*
|
||||
* @param {string=} backPaginationToken token for back-paginating the new timeline
|
||||
*/
|
||||
EventTimelineList.prototype.resetLiveTimeline = function(backPaginationToken) {
|
||||
EventTimelineSet.prototype.resetLiveTimeline = function(backPaginationToken) {
|
||||
var newTimeline;
|
||||
|
||||
if (!this._timelineSupport) {
|
||||
@@ -150,7 +150,7 @@ EventTimelineList.prototype.resetLiveTimeline = function(backPaginationToken) {
|
||||
* @return {?module:models/event-timeline~EventTimeline} timeline containing
|
||||
* the given event, or null if unknown
|
||||
*/
|
||||
EventTimelineList.prototype.getTimelineForEvent = function(eventId) {
|
||||
EventTimelineSet.prototype.getTimelineForEvent = function(eventId) {
|
||||
var res = this._eventIdToTimeline[eventId];
|
||||
return (res === undefined) ? null : res;
|
||||
};
|
||||
@@ -161,7 +161,7 @@ EventTimelineList.prototype.getTimelineForEvent = function(eventId) {
|
||||
* @param {string} eventId event ID to look for
|
||||
* @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);
|
||||
if (!tl) {
|
||||
return undefined;
|
||||
@@ -175,7 +175,7 @@ EventTimelineList.prototype.findEventById = function(eventId) {
|
||||
*
|
||||
* @return {module:models/event-timeline~EventTimeline} newly-created timeline
|
||||
*/
|
||||
EventTimelineList.prototype.addTimeline = function() {
|
||||
EventTimelineSet.prototype.addTimeline = function() {
|
||||
if (!this._timelineSupport) {
|
||||
throw new Error("timeline support is disabled. Set the 'timelineSupport'" +
|
||||
" parameter to true when creating MatrixClient to enable" +
|
||||
@@ -207,18 +207,18 @@ EventTimelineList.prototype.addTimeline = function() {
|
||||
* @fires module:client~MatrixClient#event:"Room.timeline"
|
||||
*
|
||||
*/
|
||||
EventTimelineList.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
||||
EventTimelineSet.prototype.addEventsToTimeline = function(events, toStartOfTimeline,
|
||||
timeline, paginationToken) {
|
||||
if (!timeline) {
|
||||
throw new Error(
|
||||
"'timeline' not specified for EventTimelineList.addEventsToTimeline"
|
||||
"'timeline' not specified for EventTimelineSet.addEventsToTimeline"
|
||||
);
|
||||
}
|
||||
|
||||
if (!toStartOfTimeline && timeline == this._liveTimeline) {
|
||||
throw new Error(
|
||||
"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
|
||||
*/
|
||||
EventTimelineList.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
||||
EventTimelineSet.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
||||
if (this._filter) {
|
||||
var events = this._filter.filterRoomTimeline([event]);
|
||||
if (!events) return;
|
||||
@@ -376,7 +376,7 @@ EventTimelineList.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
||||
var timeline = this._eventIdToTimeline[event.getId()];
|
||||
if (timeline) {
|
||||
if (duplicateStrategy === "replace") {
|
||||
debuglog("EventTimelineList.addLiveEvent: replacing duplicate event " +
|
||||
debuglog("EventTimelineSet.addLiveEvent: replacing duplicate event " +
|
||||
event.getId());
|
||||
var tlEvents = timeline.getEvents();
|
||||
for (var j = 0; j < tlEvents.length; j++) {
|
||||
@@ -397,7 +397,7 @@ EventTimelineList.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debuglog("EventTimelineList.addLiveEvent: ignoring duplicate event " +
|
||||
debuglog("EventTimelineSet.addLiveEvent: ignoring duplicate event " +
|
||||
event.getId());
|
||||
}
|
||||
return;
|
||||
@@ -420,7 +420,7 @@ EventTimelineList.prototype.addLiveEvent = function(event, duplicateStrategy) {
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
EventTimelineList.prototype.addEventToTimeline = function(event, timeline, toStartOfTimeline) {
|
||||
EventTimelineSet.prototype.addEventToTimeline = function(event, timeline, toStartOfTimeline) {
|
||||
var eventId = event.getId();
|
||||
timeline.addEvent(event, toStartOfTimeline);
|
||||
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);
|
||||
};
|
||||
|
||||
EventTimelineList.prototype.replaceOrAddEvent = function(localEvent, oldEventId, newEventId) {
|
||||
EventTimelineSet.prototype.replaceOrAddEvent = function(localEvent, oldEventId, newEventId) {
|
||||
var existingTimeline = this._eventIdToTimeline[oldEventId];
|
||||
if (existingTimeline) {
|
||||
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
|
||||
* in this room.
|
||||
*/
|
||||
EventTimelineList.prototype.removeEvent = function(eventId) {
|
||||
EventTimelineSet.prototype.removeEvent = function(eventId) {
|
||||
var timeline = this._eventIdToTimeline[eventId];
|
||||
if (!timeline) {
|
||||
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
|
||||
* up).
|
||||
*/
|
||||
EventTimelineList.prototype.compareEventOrdering = function(eventId1, eventId2) {
|
||||
EventTimelineSet.prototype.compareEventOrdering = function(eventId1, eventId2) {
|
||||
if (eventId1 == eventId2) {
|
||||
// optimise this case
|
||||
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.
|
||||
@@ -565,7 +565,8 @@ module.exports = EventTimelineList;
|
||||
* added to the end of the live timeline
|
||||
*
|
||||
* @example
|
||||
* matrixClient.on("Room.timeline", function(event, room, toStartOfTimeline, data){
|
||||
* matrixClient.on("Room.timeline",
|
||||
* function(event, room, toStartOfTimeline, removed, data) {
|
||||
* if (!toStartOfTimeline && data.liveEvent) {
|
||||
* var messageToAppend = room.timeline.[room.timeline.length - 1];
|
||||
* }
|
||||
@@ -583,3 +584,4 @@ module.exports = EventTimelineList;
|
||||
* @event module:client~MatrixClient#"Room.timelineReset"
|
||||
* @param {Room} room The room whose live timeline was reset.
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ var MatrixEvent = require("./event").MatrixEvent;
|
||||
var utils = require("../utils");
|
||||
var ContentRepo = require("../content-repo");
|
||||
var EventTimeline = require("./event-timeline");
|
||||
var EventTimelineList = require("./event-timeline-list");
|
||||
var EventTimelineSet = require("./event-timeline-set");
|
||||
|
||||
|
||||
// var DEBUG = false;
|
||||
@@ -162,18 +162,18 @@ function Room(roomId, opts) {
|
||||
|
||||
// all our per-room timeline lists. the first one is the unfiltered ones;
|
||||
// the subsequent ones are the filtered ones in no particular order.
|
||||
this._timelineLists = [ new EventTimelineList(roomId, this, opts) ];
|
||||
reEmit(this, this._timelineLists[0], [ "Room.timeline" ]);
|
||||
this._timelineSets = [ new EventTimelineSet(roomId, this, opts) ];
|
||||
reEmit(this, this._timelineSets[0], [ "Room.timeline" ]);
|
||||
|
||||
this._fixUpLegacyTimelineFields();
|
||||
|
||||
// any filtered timeline lists we're maintaining for this room
|
||||
this._filteredTimelineLists = {
|
||||
// filter_id: timelineList
|
||||
this._filteredTimelineSets = {
|
||||
// filter_id: timelineSet
|
||||
};
|
||||
|
||||
// a reference to our shared notification timeline list
|
||||
this._notifTimelineList = opts.notifTimelineList;
|
||||
this._notifTimelineSet = opts.notifTimelineSet;
|
||||
|
||||
if (this._opts.pendingEventOrdering == "detached") {
|
||||
this._pendingEventList = [];
|
||||
@@ -205,7 +205,7 @@ Room.prototype.getPendingEvents = function() {
|
||||
* @return {module:models/event-timeline~EventTimeline} live timeline
|
||||
*/
|
||||
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) {
|
||||
var newTimeline;
|
||||
|
||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
||||
this._timelineLists[i].resetLiveTimeline(backPaginationToken);
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
this._timelineSets[i].resetLiveTimeline(backPaginationToken);
|
||||
}
|
||||
|
||||
this._fixUpLegacyTimelineFields();
|
||||
@@ -239,9 +239,9 @@ Room.prototype._fixUpLegacyTimelineFields = function() {
|
||||
// and this.oldState and this.currentState as references to the
|
||||
// state at the start and end of that timeline. These are more
|
||||
// for backwards-compatibility than anything else.
|
||||
this.timeline = this._timelineLists[0].getLiveTimeline().getEvents();
|
||||
this.oldState = this._timelineLists[0].getLiveTimeline().getState(EventTimeline.BACKWARDS);
|
||||
this.currentState = this._timelineLists[0].getLiveTimeline().getState(EventTimeline.FORWARDS);
|
||||
this.timeline = this._timelineSets[0].getLiveTimeline().getEvents();
|
||||
this.oldState = this._timelineSets[0].getLiveTimeline().getState(EventTimeline.BACKWARDS);
|
||||
this.currentState = this._timelineSets[0].getLiveTimeline().getState(EventTimeline.FORWARDS);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -253,7 +253,7 @@ Room.prototype._fixUpLegacyTimelineFields = function() {
|
||||
*/
|
||||
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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,
|
||||
timeline, paginationToken) {
|
||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
||||
this._timelineLists[0].addEventsToTimeline(
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
this._timelineSets[0].addEventsToTimeline(
|
||||
events, toStartOfTimeline,
|
||||
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) {
|
||||
var timelineList = new EventTimelineList(
|
||||
Room.prototype.addFilteredTimelineSet = function(filter) {
|
||||
var timelineSet = new EventTimelineSet(
|
||||
this.roomId, this, {
|
||||
filter: filter,
|
||||
}
|
||||
);
|
||||
reEmit(this, timelineList, [ "Room.timeline" ]);
|
||||
this._filteredTimelineLists[filter.filterId] = timelineList;
|
||||
this._timelineLists.push(timelineList);
|
||||
reEmit(this, timelineSet, [ "Room.timeline" ]);
|
||||
this._filteredTimelineSets[filter.filterId] = timelineSet;
|
||||
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) {
|
||||
var timelineList = this._filteredTimelineLists[filter.filterId];
|
||||
delete this._filteredTimelineLists[filter.filterId];
|
||||
var i = this._timelineLists.indexOf(timelineList);
|
||||
Room.prototype.removeFilteredTimelineSet = function(filter) {
|
||||
var timelineSet = this._filteredTimelineSets[filter.filterId];
|
||||
delete this._filteredTimelineSets[filter.filterId];
|
||||
var i = this._timelineSets.indexOf(timelineSet);
|
||||
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") {
|
||||
var redactId = event.event.redacts;
|
||||
|
||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
||||
var timelineList = this._timelineLists[i];
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
var timelineSet = this._timelineSets[i];
|
||||
// if we know about this event, redact its contents now.
|
||||
var redactedEvent = timelineList.findEventById(redactId);
|
||||
var redactedEvent = timelineSet.findEventById(redactId);
|
||||
if (redactedEvent) {
|
||||
redactedEvent.makeRedacted(event);
|
||||
// FIXME: these should be emitted from EventTimelineList probably
|
||||
this.emit("Room.redaction", event, this, timelineList);
|
||||
// FIXME: these should be emitted from EventTimelineSet probably
|
||||
this.emit("Room.redaction", event, this, timelineSet);
|
||||
|
||||
// TODO: we stash user displaynames (among other things) in
|
||||
// RoomMember objects which are then attached to other events
|
||||
@@ -527,14 +527,14 @@ Room.prototype._addLiveEvent = function(event, duplicateStrategy) {
|
||||
}
|
||||
|
||||
// add to our timeline lists
|
||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
||||
this._timelineLists[i].addLiveEvent(event, duplicateStrategy);
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
this._timelineSets[i].addLiveEvent(event, duplicateStrategy);
|
||||
}
|
||||
|
||||
// add to notification timeline list, if any
|
||||
if (this._notifTimelineList) {
|
||||
if (this._notifTimelineSet) {
|
||||
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
|
||||
// as event is shared over all timelinelists, we set up its metadata based
|
||||
// on the unfiltered timelineList.
|
||||
// as event is shared over all timelineSets, we set up its metadata based
|
||||
// on the unfiltered timelineSet.
|
||||
EventTimeline.setEventMetadata(
|
||||
event,
|
||||
this._timelineLists[0].getLiveTimeline().getState(EventTimeline.FORWARDS),
|
||||
this._timelineSets[0].getLiveTimeline().getState(EventTimeline.FORWARDS),
|
||||
false
|
||||
);
|
||||
|
||||
@@ -598,10 +598,10 @@ Room.prototype.addPendingEvent = function(event, txnId) {
|
||||
if (this._opts.pendingEventOrdering == "detached") {
|
||||
this._pendingEventList.push(event);
|
||||
} else {
|
||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
||||
this._timelineLists[i].addEventToTimeline(event, this._timelineLists[i].getLiveTimeline(), false);
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
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);
|
||||
@@ -645,11 +645,11 @@ Room.prototype._handleRemoteEcho = function(remoteEvent, localEvent) {
|
||||
// successfully sent.
|
||||
localEvent.status = null;
|
||||
|
||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
||||
var timelineList = this._timelineLists[i];
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
var timelineSet = this._timelineSets[i];
|
||||
|
||||
// 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,
|
||||
@@ -705,7 +705,7 @@ Room.prototype.updatePendingEvent = function(event, newStatus, newEventId) {
|
||||
|
||||
// SENT races against /sync, so we have to special-case it.
|
||||
if (newStatus == EventStatus.SENT) {
|
||||
var timeline = this._timelineLists[0].eventIdToTimeline(newEventId);
|
||||
var timeline = this._timelineSets[0].eventIdToTimeline(newEventId);
|
||||
if (timeline) {
|
||||
// we've already received the event via the event stream.
|
||||
// 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
|
||||
// opts.pendingEventOrdering==chronological), we need to update the
|
||||
// timeline map.
|
||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
||||
this._timelineLists[i].replaceEventId(oldEventId, newEventId);
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
this._timelineSets[i].replaceEventId(oldEventId, newEventId);
|
||||
}
|
||||
}
|
||||
else if (newStatus == EventStatus.CANCELLED) {
|
||||
@@ -778,12 +778,12 @@ Room.prototype.addLiveEvents = function(events, duplicateStrategy) {
|
||||
}
|
||||
|
||||
// sanity check that the live timeline is still live
|
||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
||||
var liveTimeline = this._timelineLists[i].getLiveTimeline();
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
var liveTimeline = this._timelineSets[i].getLiveTimeline();
|
||||
if (liveTimeline.getPaginationToken(EventTimeline.FORWARDS)) {
|
||||
throw new Error(
|
||||
"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)) {
|
||||
@@ -830,8 +830,8 @@ Room.prototype.removeEvents = function(event_ids) {
|
||||
*/
|
||||
Room.prototype.removeEvent = function(eventId) {
|
||||
var removedAny;
|
||||
for (var i = 0; i < this._timelineLists.length; i++) {
|
||||
var removed = this._timelineLists[i].removeEvent(eventId);
|
||||
for (var i = 0; i < this._timelineSets.length; i++) {
|
||||
var removed = this._timelineSets[i].removeEvent(eventId);
|
||||
if (removed) {
|
||||
removedAny = true;
|
||||
}
|
||||
@@ -992,7 +992,7 @@ Room.prototype._addReceiptsToStructure = function(event, receipts) {
|
||||
// than the one we already have. (This is managed
|
||||
// server-side, but because we synthesize RRs locally we
|
||||
// have to do it here too.)
|
||||
var ordering = self._timelineLists[0].compareEventOrdering(
|
||||
var ordering = self._timelineSets[0].compareEventOrdering(
|
||||
existingReceipt.eventId, eventId);
|
||||
if (ordering !== null && ordering >= 0) {
|
||||
return;
|
||||
|
||||
@@ -479,13 +479,13 @@ describe("Room", function() {
|
||||
it("should handle events in the same timeline", function() {
|
||||
room.addLiveEvents(events);
|
||||
|
||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(),
|
||||
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(),
|
||||
events[1].getId()))
|
||||
.toBeLessThan(0);
|
||||
expect(room._timelineLists[0].compareEventOrdering(events[2].getId(),
|
||||
expect(room._timelineSets[0].compareEventOrdering(events[2].getId(),
|
||||
events[1].getId()))
|
||||
.toBeGreaterThan(0);
|
||||
expect(room._timelineLists[0].compareEventOrdering(events[1].getId(),
|
||||
expect(room._timelineSets[0].compareEventOrdering(events[1].getId(),
|
||||
events[1].getId()))
|
||||
.toEqual(0);
|
||||
});
|
||||
@@ -498,10 +498,10 @@ describe("Room", function() {
|
||||
room.addEventsToTimeline([events[0]], false, oldTimeline);
|
||||
room.addLiveEvents([events[1]]);
|
||||
|
||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(),
|
||||
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(),
|
||||
events[1].getId()))
|
||||
.toBeLessThan(0);
|
||||
expect(room._timelineLists[0].compareEventOrdering(events[1].getId(),
|
||||
expect(room._timelineSets[0].compareEventOrdering(events[1].getId(),
|
||||
events[0].getId()))
|
||||
.toBeGreaterThan(0);
|
||||
});
|
||||
@@ -512,10 +512,10 @@ describe("Room", function() {
|
||||
room.addEventsToTimeline([events[0]], false, oldTimeline);
|
||||
room.addLiveEvents([events[1]]);
|
||||
|
||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(),
|
||||
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(),
|
||||
events[1].getId()))
|
||||
.toBe(null);
|
||||
expect(room._timelineLists[0].compareEventOrdering(events[1].getId(),
|
||||
expect(room._timelineSets[0].compareEventOrdering(events[1].getId(),
|
||||
events[0].getId()))
|
||||
.toBe(null);
|
||||
});
|
||||
@@ -523,11 +523,11 @@ describe("Room", function() {
|
||||
it("should return null for unknown events", function() {
|
||||
room.addLiveEvents(events);
|
||||
|
||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(), "xxx"))
|
||||
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(), "xxx"))
|
||||
.toBe(null);
|
||||
expect(room._timelineLists[0].compareEventOrdering("xxx", events[0].getId()))
|
||||
expect(room._timelineSets[0].compareEventOrdering("xxx", events[0].getId()))
|
||||
.toBe(null);
|
||||
expect(room._timelineLists[0].compareEventOrdering(events[0].getId(),
|
||||
expect(room._timelineSets[0].compareEventOrdering(events[0].getId(),
|
||||
events[0].getId()))
|
||||
.toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user