Merge pull request #1789 from matrix-org/dbkr/presence_only_on_user_activity

Don't reset the presence timer on every dispatch
This commit is contained in:
Matthew Hodgson 2018-03-06 20:18:00 +00:00 committed by GitHub
commit 7a77da7a4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,6 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -31,7 +32,7 @@ class Presence {
this.running = true;
if (undefined === this.state) {
this._resetTimer();
this.dispatcherRef = dis.register(this._onUserActivity.bind(this));
this.dispatcherRef = dis.register(this._onAction.bind(this));
}
}
@ -125,9 +126,10 @@ class Presence {
this.setState("unavailable");
}
_onUserActivity(payload) {
if (payload.action === "sync_state" || payload.action === "self_presence_updated") return;
this._resetTimer();
_onAction(payload) {
if (payload.action === "user_activity") {
this._resetTimer();
}
}
/**