diff --git a/lib/models/room-member.js b/lib/models/room-member.js index d27ea3a31..faad4253b 100644 --- a/lib/models/room-member.js +++ b/lib/models/room-member.js @@ -134,6 +134,12 @@ RoomMember.prototype._updateModifiedTime = function() { this._modified = Date.now(); }; +/** + * Get the timestamp when this RoomMember was last updated. This timestamp is + * updated when properties on this RoomMember are updated. + * It is updated before firing events. + * @return {number} The timestamp + */ RoomMember.prototype.getLastModifiedTime = function() { return this._modified; }; diff --git a/lib/models/room-state.js b/lib/models/room-state.js index 45ef26512..0f295423b 100644 --- a/lib/models/room-state.js +++ b/lib/models/room-state.js @@ -30,6 +30,7 @@ function RoomState(roomId) { this._sentinels = { // userId: RoomMember }; + this._updateModifiedTime(); } utils.inherits(RoomState, EventEmitter); @@ -96,6 +97,7 @@ RoomState.prototype.getStateEvents = function(eventType, stateKey) { */ RoomState.prototype.setStateEvents = function(stateEvents) { var self = this; + this._updateModifiedTime(); // update the core event dict utils.forEach(stateEvents, function(event) { @@ -162,6 +164,19 @@ RoomState.prototype.setTypingEvent = function(event) { }); }; +RoomState.prototype._updateModifiedTime = function() { + this._modified = Date.now(); +}; + +/** + * Get the timestamp when this room state was last updated. This timestamp is + * updated when this object has received new state events. + * @return {number} The timestamp + */ +RoomState.prototype.getLastModifiedTime = function() { + return this._modified; +}; + /** * The RoomState class. */ diff --git a/lib/models/user.js b/lib/models/user.js index fff6e2322..0d87221e4 100644 --- a/lib/models/user.js +++ b/lib/models/user.js @@ -78,6 +78,12 @@ User.prototype._updateModifiedTime = function() { this._modified = Date.now(); }; +/** + * Get the timestamp when this User was last updated. This timestamp is + * updated when this User receives a new Presence event which has updated a + * property on this object. It is updated before firing events. + * @return {number} The timestamp + */ User.prototype.getLastModifiedTime = function() { return this._modified; };