PR feedback

pull/21833/head
David Baker 2019-03-08 17:41:04 +00:00
parent 7e424ce95b
commit b404d21bba
1 changed files with 10 additions and 5 deletions

View File

@ -23,7 +23,11 @@ import Timer from './utils/Timer';
// such as READ_MARKER_INVIEW_THRESHOLD_MS, // such as READ_MARKER_INVIEW_THRESHOLD_MS,
// READ_MARKER_OUTOFVIEW_THRESHOLD_MS, // READ_MARKER_OUTOFVIEW_THRESHOLD_MS,
// READ_RECEIPT_INTERVAL_MS in TimelinePanel // READ_RECEIPT_INTERVAL_MS in TimelinePanel
// 'Under a few seconds'. Must be less than 'CURRENTLY_PASSIVE_THRESHOLD_MS'
const CURRENTLY_ACTIVE_THRESHOLD_MS = 700; const CURRENTLY_ACTIVE_THRESHOLD_MS = 700;
// 'Under a few minutes'.
const CURRENTLY_PASSIVE_THRESHOLD_MS = 2 * 60 * 1000; const CURRENTLY_PASSIVE_THRESHOLD_MS = 2 * 60 * 1000;
/** /**
@ -108,9 +112,9 @@ export default class UserActivity {
* Start listening to user activity * Start listening to user activity
*/ */
start() { start() {
this._document.onmousedown = this._onUserActivity; this._document.addEventListener('mousedown', this._onUserActivity);
this._document.onmousemove = this._onUserActivity; this._document.addEventListener('mousemove', this._onUserActivity);
this._document.onkeydown = this._onUserActivity; this._document.addEventListener('keydown', this._onUserActivity);
this._document.addEventListener("visibilitychange", this._onPageVisibilityChanged); this._document.addEventListener("visibilitychange", this._onPageVisibilityChanged);
this._window.addEventListener("blur", this._onWindowBlurred); this._window.addEventListener("blur", this._onWindowBlurred);
this._window.addEventListener("focus", this._onUserActivity); this._window.addEventListener("focus", this._onUserActivity);
@ -118,8 +122,9 @@ export default class UserActivity {
// itself being scrolled. Need to use addEventListener's useCapture. // itself being scrolled. Need to use addEventListener's useCapture.
// also this needs to be the wheel event, not scroll, as scroll is // also this needs to be the wheel event, not scroll, as scroll is
// fired when the view scrolls down for a new message. // fired when the view scrolls down for a new message.
this._window.addEventListener('wheel', this._onUserActivity, this._window.addEventListener('wheel', this._onUserActivity, {
{ passive: true, capture: true }); passive: true, capture: true,
});
} }
/** /**