1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +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

@@ -655,6 +655,8 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) {
}
}
this.notifEvents = [];
// Handle invites
inviteRooms.forEach(function(inviteObj) {
var room = inviteObj.room;
@@ -788,6 +790,16 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) {
timelineEvents.forEach(function(e) { client.emit("event", e); });
accountDataEvents.forEach(function(e) { client.emit("event", e); });
});
// update the notification timeline, if appropriate
if (this.notifEvents.length) {
this.notifEvents.sort(function(a, b) {
return a.getTs() - b.getTs();
});
this.notifEvents.forEach(function(event) {
client.getNotifTimelineSet().addLiveEvent(event);
});
}
};
/**
@@ -976,6 +988,16 @@ SyncApi.prototype._processRoomEvents = function(room, stateEventList,
// may make notifications appear which should have the right name.
room.recalculate(this.client.credentials.userId);
// gather our notifications into this.notifEvents
if (client.getNotifTimelineSet()) {
for (var i = 0; i < timelineEventList.length; i++) {
var pushActions = client.getPushActionsForEvent(timelineEventList[i]);
if (pushActions && pushActions.notify) {
this.notifEvents.push(timelineEventList[i]);
}
}
}
// execute the timeline events, this will begin to diverge the current state
// if the timeline has any state events in it.
room.addLiveEvents(timelineEventList);