1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

trivially add content.currently_active in m.presence events.

This commit is contained in:
Matthew Hodgson
2016-03-16 22:35:55 +00:00
parent a68b61dafe
commit f7bc11361c

View File

@@ -31,6 +31,8 @@ limitations under the License.
* @prop {string} avatarUrl The 'avatar_url' of the user if known. * @prop {string} avatarUrl The 'avatar_url' of the user if known.
* @prop {string} presence The presence enum if known. * @prop {string} presence The presence enum if known.
* @prop {Number} lastActiveAgo The last time the user performed some action in ms. * @prop {Number} lastActiveAgo The last time the user performed some action in ms.
* @prop {Boolean} currentlyActive Whether we should consider lastActiveAgo to be
* an approximation and that the user should be seen as active 'now'
* @prop {Object} events The events describing this user. * @prop {Object} events The events describing this user.
* @prop {MatrixEvent} events.presence The m.presence event for this user. * @prop {MatrixEvent} events.presence The m.presence event for this user.
*/ */
@@ -40,6 +42,7 @@ function User(userId) {
this.displayName = userId; this.displayName = userId;
this.avatarUrl = null; this.avatarUrl = null;
this.lastActiveAgo = 0; this.lastActiveAgo = 0;
this.currentlyActive = false;
this.events = { this.events = {
presence: null, presence: null,
profile: null profile: null
@@ -79,6 +82,7 @@ User.prototype.setPresenceEvent = function(event) {
this.displayName = event.getContent().displayname; this.displayName = event.getContent().displayname;
this.avatarUrl = event.getContent().avatar_url; this.avatarUrl = event.getContent().avatar_url;
this.lastActiveAgo = event.getContent().last_active_ago; this.lastActiveAgo = event.getContent().last_active_ago;
this.currentlyActive = event.getContent().currently_active;
if (eventsToFire.length > 0) { if (eventsToFire.length > 0) {
this._updateModifiedTime(); this._updateModifiedTime();