diff --git a/lib/sync.js b/lib/sync.js index 4d1cd71e9..cb91c46d4 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -246,7 +246,8 @@ SyncApi.prototype._sync = function(syncOptions, attempt) { // state: { events: [] }, // timeline: { events: [], prev_batch: $token, limited: true }, // ephemeral: { events: [] }, - // account_data: { events: [] } + // account_data: { events: [] }, + // unread_notification_count: 0 // } // }, // leave: { @@ -326,6 +327,9 @@ SyncApi.prototype._sync = function(syncOptions, attempt) { var ephemeralEvents = self._mapSyncEventsFormat(joinObj.ephemeral); var accountDataEvents = self._mapSyncEventsFormat(joinObj.account_data); + // we do this first so it's correct when any of the events fire + room.unread_notification_count = joinObj.unread_notification_count; + joinObj.timeline = joinObj.timeline || {}; if (joinObj.timeline.limited) {