diff --git a/lib/client.js b/lib/client.js index 36a23e63c..c257edffb 100644 --- a/lib/client.js +++ b/lib/client.js @@ -909,7 +909,7 @@ MatrixClient.prototype.getUsers = function() { /** * Set account data event for the current user. * @param {string} eventType The event type - * @param {Object} the contents object for the event + * @param {Object} content the contents object for the event * @param {module:client.callback} callback Optional. * @return {module:client.Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. diff --git a/lib/store/memory.js b/lib/store/memory.js index 311478d74..26a397817 100644 --- a/lib/store/memory.js +++ b/lib/store/memory.js @@ -250,7 +250,9 @@ module.exports.MatrixInMemoryStore.prototype = { }, /** - * Store user-scoped account data events + * Store user-scoped account data events. + * N.B. that account data only allows a single event per type, so multiple + * events with the same type will replace each other. * @param {Array} events The events to store. */ storeAccountDataEvents: function(events) { @@ -263,7 +265,7 @@ module.exports.MatrixInMemoryStore.prototype = { /** * Get account data event by event type * @param {string} eventType The event type being queried - * @return {MatrixEvent} the user account_data event of given type + * @return {?MatrixEvent} the user account_data event of given type, if any */ getAccountData: function(eventType) { return this.accountData[eventType]; diff --git a/lib/sync.js b/lib/sync.js index f7c6e98ea..24c77a2ca 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -608,13 +608,13 @@ SyncApi.prototype._processSyncResponse = function(syncToken, data) { // handle non-room account_data if (data.account_data && utils.isArray(data.account_data.events)) { - client.store.storeAccountDataEvents( - data.account_data.events.map(client.getEventMapper()).map( - function(accountDataEvent) { - client.emit("accountData", accountDataEvent); - return accountDataEvent; - } - ) + var events = data.account_data.events.map(client.getEventMapper()); + client.store.storeAccountDataEvents(events); + events.forEach( + function(accountDataEvent) { + client.emit("accountData", accountDataEvent); + return accountDataEvent; + } ); }