diff --git a/src/sync-accumulator.js b/src/sync-accumulator.js index 942c319eb..786841318 100644 --- a/src/sync-accumulator.js +++ b/src/sync-accumulator.js @@ -57,7 +57,8 @@ class SyncAccumulator { // { event: $event, token: null|token }, // ... // ], - // _accountData: { $event_type: json } + // _accountData: { $event_type: json }, + // _unreadNotifications: { ... unread_notifications JSON ... } //} }; // the /sync token which corresponds to the last time rooms were @@ -218,6 +219,7 @@ class SyncAccumulator { _currentState: Object.create(null), _timeline: [], _accountData: Object.create(null), + _unreadNotifications: {}, }; } const currentData = this.joinRooms[roomId]; @@ -229,6 +231,11 @@ class SyncAccumulator { }); } + // these probably clobber, spec is unclear. + if (data.unread_notifications) { + currentData._unreadNotifications = data.unread_notifications; + } + // Work out the current state. The deltas need to be applied in the order: // - existing state which didn't come down /sync. // - State events under the 'state' key. @@ -306,6 +313,7 @@ class SyncAccumulator { events: [], prev_batch: null, }, + unread_notifications: roomData._unreadNotifications, }; // Add account data Object.keys(roomData._accountData).forEach((evType) => {