From a97e7375d5d4f30cae4844a26f746762d5d4d813 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 6 Mar 2018 17:48:21 +0000 Subject: [PATCH] Don't reset the presence timer on every dispatch Only on user activity (there's now a dispatch every time we set a member event, ie. A LOT, hence this now being a problem) --- src/Presence.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Presence.js b/src/Presence.js index 2652c64c96..fd9bcf516d 100644 --- a/src/Presence.js +++ b/src/Presence.js @@ -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(); + } } /**