You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
track lastPresenceTs
This commit is contained in:
@@ -609,6 +609,7 @@ Room.prototype._addEventToTimeline = function(event, timeline, toStartOfTimeline
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Room.prototype._addLiveEvents = function(events) {
|
Room.prototype._addLiveEvents = function(events) {
|
||||||
|
// var now = Date.now();
|
||||||
for (var i = 0; i < events.length; i++) {
|
for (var i = 0; i < events.length; i++) {
|
||||||
if (events[i].getType() === "m.room.redaction") {
|
if (events[i].getType() === "m.room.redaction") {
|
||||||
var redactId = events[i].event.redacts;
|
var redactId = events[i].event.redacts;
|
||||||
@@ -652,6 +653,16 @@ Room.prototype._addLiveEvents = function(events) {
|
|||||||
this.addReceipt(synthesizeReceipt(
|
this.addReceipt(synthesizeReceipt(
|
||||||
events[i].sender.userId, events[i], "m.read"
|
events[i].sender.userId, events[i], "m.read"
|
||||||
), true);
|
), true);
|
||||||
|
|
||||||
|
// also, any live events from a user should be taken as implicit
|
||||||
|
// presence information: evidence that they are currently active.
|
||||||
|
// ...except in a world where we use 'user.currentlyActive' to reduce
|
||||||
|
// presence spam, this isn't very useful - we'll get a transition when
|
||||||
|
// they are no longer currently active anyway. so comment it out for now.
|
||||||
|
|
||||||
|
// var user = this.currentState.getMember(events[i].sender.userId);
|
||||||
|
// user.lastActiveAgo = 0;
|
||||||
|
// user.lastPresenceTs = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,7 +30,12 @@ limitations under the License.
|
|||||||
* @prop {string} displayName The 'displayname' of the user if known.
|
* @prop {string} displayName The 'displayname' of the user if known.
|
||||||
* @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 time elapsed in ms since the user interacted
|
||||||
|
* proactively with the server, or we saw a message from the user
|
||||||
|
* @prop {Number} lastPresenceTs Timestamp (ms since the epoch) for when we last
|
||||||
|
* received presence data for this user. We can subtract
|
||||||
|
* lastActiveAgo from this to approximate an absolute value for
|
||||||
|
* when a user was last active.
|
||||||
* @prop {Boolean} currentlyActive Whether we should consider lastActiveAgo to be
|
* @prop {Boolean} currentlyActive Whether we should consider lastActiveAgo to be
|
||||||
* an approximation and that the user should be seen as active 'now'
|
* 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.
|
||||||
@@ -42,6 +47,7 @@ function User(userId) {
|
|||||||
this.displayName = userId;
|
this.displayName = userId;
|
||||||
this.avatarUrl = null;
|
this.avatarUrl = null;
|
||||||
this.lastActiveAgo = 0;
|
this.lastActiveAgo = 0;
|
||||||
|
this.lastPresenceTs = 0;
|
||||||
this.currentlyActive = false;
|
this.currentlyActive = false;
|
||||||
this.events = {
|
this.events = {
|
||||||
presence: null,
|
presence: null,
|
||||||
@@ -82,6 +88,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.lastPresenceTs = Date.now();
|
||||||
this.currentlyActive = event.getContent().currently_active;
|
this.currentlyActive = event.getContent().currently_active;
|
||||||
|
|
||||||
if (eventsToFire.length > 0) {
|
if (eventsToFire.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user