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

maintain the global notification timeline set.

* track notifTimelineSet on MatrixClient
* stop Rooms from tracking notifTimelineSet as they don't need to
* Implement client.paginateNotifTimelineSet
* make Events store their pushActions properly
* insert live notifs directly into the notifTimelineSet in /sync, ordering by origin_server_ts.
This commit is contained in:
Matthew Hodgson
2016-09-08 02:57:49 +01:00
parent fc495a5f1e
commit e4ec2aa55f
6 changed files with 164 additions and 29 deletions

View File

@@ -149,21 +149,18 @@ function Room(roomId, opts) {
this._notificationCounts = {};
// all our per-room timeline lists. the first one is the unfiltered ones;
// all our per-room timeline sets. the first one is the unfiltered ones;
// the subsequent ones are the filtered ones in no particular order.
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
// any filtered timeline sets we're maintaining for this room
this._filteredTimelineSets = {
// filter_id: timelineSet
};
// a reference to our shared notification timeline list
this._notifTimelineSet = opts.notifTimelineSet;
if (this._opts.pendingEventOrdering == "detached") {
this._pendingEventList = [];
}
@@ -241,14 +238,6 @@ Room.prototype.getTimelineSets = function() {
return this._timelineSets;
};
/**
* Return the shared notification timeline set
* @return {EventTimelineSet} notification timeline set
*/
Room.prototype.getNotifTimelineSet = function() {
return this._notifTimelineSet;
};
/**
* Get the timeline which contains the given event from the unfiltered set, if any
*
@@ -261,7 +250,7 @@ Room.prototype.getTimelineForEvent = function(eventId) {
};
/**
* Add a new timeline to this room's unfiltered timeline list
* Add a new timeline to this room's unfiltered timeline set
*
* @return {module:models/event-timeline~EventTimeline} newly-created timeline
*/
@@ -563,18 +552,11 @@ Room.prototype._addLiveEvent = function(event, duplicateStrategy) {
}
}
// add to our timeline lists
// add to our timeline sets
for (i = 0; i < this._timelineSets.length; i++) {
this._timelineSets[i].addLiveEvent(event, duplicateStrategy);
}
// add to notification timeline list, if any
if (this._notifTimelineSet) {
if (event.isNotification()) {
this._notifTimelineSet.addLiveEvent(event, duplicateStrategy);
}
}
// synthesize and inject implicit read receipts
// Done after adding the event because otherwise the app would get a read receipt
// pointing to an event that wasn't yet in the timeline
@@ -648,8 +630,6 @@ Room.prototype.addPendingEvent = function(event, txnId) {
timelineSet.getLiveTimeline(), false);
}
}
// notifications are receive-only, so we don't need to worry
// about this._notifTimelineSet.
}
this.emit("Room.localEchoUpdated", event, this, null, null);