diff --git a/src/UserActivity.js b/src/UserActivity.js index dd2a46d340..02f006f274 100644 --- a/src/UserActivity.js +++ b/src/UserActivity.js @@ -24,11 +24,11 @@ import Timer from './utils/Timer'; // READ_MARKER_OUTOFVIEW_THRESHOLD_MS, // READ_RECEIPT_INTERVAL_MS in TimelinePanel -// 'Under a few seconds'. Must be less than 'CURRENTLY_PASSIVE_THRESHOLD_MS' +// 'Under a few seconds'. Must be less than 'RECENTLY_ACTIVE_THRESHOLD_MS' const CURRENTLY_ACTIVE_THRESHOLD_MS = 700; // 'Under a few minutes'. -const CURRENTLY_PASSIVE_THRESHOLD_MS = 2 * 60 * 1000; +const RECENTLY_ACTIVE_THRESHOLD_MS = 2 * 60 * 1000; /** * This class watches for user activity (moving the mouse or pressing a key) @@ -45,7 +45,7 @@ export default class UserActivity { this._attachedTimersActive = []; this._attachedTimersPassive = []; this._activeNowTimeout = new Timer(CURRENTLY_ACTIVE_THRESHOLD_MS); - this._activeRecentlyTimeout = new Timer(CURRENTLY_PASSIVE_THRESHOLD_MS); + this._activeRecentlyTimeout = new Timer(RECENTLY_ACTIVE_THRESHOLD_MS); this._onUserActivity = this._onUserActivity.bind(this); this._onWindowBlurred = this._onWindowBlurred.bind(this); this._onPageVisibilityChanged = this._onPageVisibilityChanged.bind(this); @@ -61,7 +61,7 @@ export default class UserActivity { } /** - * Runs the given timer while the user is 'active', aborting when the user is no longer + * Runs the given timer while the user is 'active now', aborting when the user is no longer * considered currently active. * See userActiveNow() for what it means for a user to be 'active'. * Can be called multiple times with the same already running timer, which is a NO-OP. @@ -69,7 +69,7 @@ export default class UserActivity { * later on when the user does become active. * @param {Timer} timer the timer to use */ - timeWhileActive(timer) { + timeWhileActiveNow(timer) { this._timeWhile(timer, this._attachedTimersActive); if (this.userActiveNow()) { timer.start(); @@ -85,7 +85,7 @@ export default class UserActivity { * later on when the user does become active. * @param {Timer} timer the timer to use */ - timeWhilePassive(timer) { + timeWhileActiveRecently(timer) { this._timeWhile(timer, this._attachedTimersPassive); if (this.userActiveRecently()) { timer.start(); diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index dcb60f8970..19adafbe4e 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -1,6 +1,7 @@ /* Copyright 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd +Copyright 2019 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. @@ -562,7 +563,7 @@ var TimelinePanel = React.createClass({ this._readMarkerActivityTimer = new Timer(initialTimeout); while (this._readMarkerActivityTimer) { //unset on unmount - UserActivity.sharedInstance().timeWhilePassive(this._readMarkerActivityTimer); + UserActivity.sharedInstance().timeWhileActiveRecently(this._readMarkerActivityTimer); try { await this._readMarkerActivityTimer.finished(); } catch(e) { continue; /* aborted */ } @@ -574,7 +575,7 @@ var TimelinePanel = React.createClass({ updateReadReceiptOnUserActivity: async function() { this._readReceiptActivityTimer = new Timer(READ_RECEIPT_INTERVAL_MS); while (this._readReceiptActivityTimer) { //unset on unmount - UserActivity.sharedInstance().timeWhileActive(this._readReceiptActivityTimer); + UserActivity.sharedInstance().timeWhileActiveNow(this._readReceiptActivityTimer); try { await this._readReceiptActivityTimer.finished(); } catch(e) { continue; /* aborted */ }