From b404d21bbaea24dffb56d86cd7c49d355a24e844 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 8 Mar 2019 17:41:04 +0000 Subject: [PATCH] PR feedback --- src/UserActivity.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/UserActivity.js b/src/UserActivity.js index a4fba65f7f..c556be8091 100644 --- a/src/UserActivity.js +++ b/src/UserActivity.js @@ -23,7 +23,11 @@ import Timer from './utils/Timer'; // such as READ_MARKER_INVIEW_THRESHOLD_MS, // READ_MARKER_OUTOFVIEW_THRESHOLD_MS, // READ_RECEIPT_INTERVAL_MS in TimelinePanel + +// 'Under a few seconds'. Must be less than 'CURRENTLY_PASSIVE_THRESHOLD_MS' const CURRENTLY_ACTIVE_THRESHOLD_MS = 700; + +// 'Under a few minutes'. const CURRENTLY_PASSIVE_THRESHOLD_MS = 2 * 60 * 1000; /** @@ -108,9 +112,9 @@ export default class UserActivity { * Start listening to user activity */ start() { - this._document.onmousedown = this._onUserActivity; - this._document.onmousemove = this._onUserActivity; - this._document.onkeydown = this._onUserActivity; + this._document.addEventListener('mousedown', this._onUserActivity); + this._document.addEventListener('mousemove', this._onUserActivity); + this._document.addEventListener('keydown', this._onUserActivity); this._document.addEventListener("visibilitychange", this._onPageVisibilityChanged); this._window.addEventListener("blur", this._onWindowBlurred); this._window.addEventListener("focus", this._onUserActivity); @@ -118,8 +122,9 @@ export default class UserActivity { // itself being scrolled. Need to use addEventListener's useCapture. // also this needs to be the wheel event, not scroll, as scroll is // fired when the view scrolls down for a new message. - this._window.addEventListener('wheel', this._onUserActivity, - { passive: true, capture: true }); + this._window.addEventListener('wheel', this._onUserActivity, { + passive: true, capture: true, + }); } /**