diff --git a/.eslintignore.errorfiles b/.eslintignore.errorfiles index 9d5525cac9..3d4207caa2 100644 --- a/.eslintignore.errorfiles +++ b/.eslintignore.errorfiles @@ -129,10 +129,8 @@ src/Notifier.js src/PlatformPeg.js src/Presence.js src/ratelimitedfunc.js -src/Resend.js src/RichText.js src/Roles.js -src/RoomListSorter.js src/Rooms.js src/ScalarAuthClient.js src/ScalarMessaging.js @@ -142,7 +140,6 @@ src/TextForEvent.js src/Tinter.js src/UiEffects.js src/Unread.js -src/UserActivity.js src/utils/DecryptFile.js src/utils/DMRoomMap.js src/utils/FormattingUtils.js diff --git a/src/Resend.js b/src/Resend.js index bbd980ea7f..1fee5854ea 100644 --- a/src/Resend.js +++ b/src/Resend.js @@ -14,10 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -var MatrixClientPeg = require('./MatrixClientPeg'); -var dis = require('./dispatcher'); -var sdk = require('./index'); -var Modal = require('./Modal'); +import MatrixClientPeg from './MatrixClientPeg'; +import dis from './dispatcher'; import { EventStatus } from 'matrix-js-sdk'; module.exports = { @@ -37,12 +35,10 @@ module.exports = { }, resend: function(event) { const room = MatrixClientPeg.get().getRoom(event.getRoomId()); - MatrixClientPeg.get().resendEvent( - event, room - ).done(function(res) { + MatrixClientPeg.get().resendEvent(event, room).done(function(res) { dis.dispatch({ action: 'message_sent', - event: event + event: event, }); }, function(err) { // XXX: temporary logging to try to diagnose @@ -58,7 +54,7 @@ module.exports = { dis.dispatch({ action: 'message_send_failed', - event: event + event: event, }); }); }, @@ -66,7 +62,7 @@ module.exports = { MatrixClientPeg.get().cancelPendingEvent(event); dis.dispatch({ action: 'message_send_cancelled', - event: event + event: event, }); }, }; diff --git a/src/Roles.js b/src/Roles.js index 8c1f711bbe..83d8192c67 100644 --- a/src/Roles.js +++ b/src/Roles.js @@ -19,7 +19,7 @@ export function levelRoleMap() { return { undefined: _t('Default'), 0: _t('User'), - 50: _t('Moderator'), + 50: _t('Moderator'), 100: _t('Admin'), }; } diff --git a/src/RoomListSorter.js b/src/RoomListSorter.js index 7a43c1891e..c06cc60c97 100644 --- a/src/RoomListSorter.js +++ b/src/RoomListSorter.js @@ -19,8 +19,7 @@ limitations under the License. function tsOfNewestEvent(room) { if (room.timeline.length) { return room.timeline[room.timeline.length - 1].getTs(); - } - else { + } else { return Number.MAX_SAFE_INTEGER; } } @@ -32,5 +31,5 @@ function mostRecentActivityFirst(roomList) { } module.exports = { - mostRecentActivityFirst: mostRecentActivityFirst + mostRecentActivityFirst, }; diff --git a/src/UserActivity.js b/src/UserActivity.js index 1ae272f5df..b6fae38ed5 100644 --- a/src/UserActivity.js +++ b/src/UserActivity.js @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -var dis = require("./dispatcher"); +import dis from './dispatcher'; -var MIN_DISPATCH_INTERVAL_MS = 500; -var CURRENTLY_ACTIVE_THRESHOLD_MS = 2000; +const MIN_DISPATCH_INTERVAL_MS = 500; +const CURRENTLY_ACTIVE_THRESHOLD_MS = 2000; /** * This class watches for user activity (moving the mouse or pressing a key) @@ -58,16 +58,15 @@ class UserActivity { /** * Return true if there has been user activity very recently * (ie. within a few seconds) + * @returns {boolean} true if user is currently/very recently active */ userCurrentlyActive() { return this.lastActivityAtTs > new Date().getTime() - CURRENTLY_ACTIVE_THRESHOLD_MS; } _onUserActivity(event) { - if (event.screenX && event.type == "mousemove") { - if (event.screenX === this.lastScreenX && - event.screenY === this.lastScreenY) - { + if (event.screenX && event.type === "mousemove") { + if (event.screenX === this.lastScreenX && event.screenY === this.lastScreenY) { // mouse hasn't actually moved return; } @@ -79,28 +78,24 @@ class UserActivity { if (this.lastDispatchAtTs < this.lastActivityAtTs - MIN_DISPATCH_INTERVAL_MS) { this.lastDispatchAtTs = this.lastActivityAtTs; dis.dispatch({ - action: 'user_activity' + action: 'user_activity', }); if (!this.activityEndTimer) { - this.activityEndTimer = setTimeout( - this._onActivityEndTimer.bind(this), MIN_DISPATCH_INTERVAL_MS - ); + this.activityEndTimer = setTimeout(this._onActivityEndTimer.bind(this), MIN_DISPATCH_INTERVAL_MS); } } } _onActivityEndTimer() { - var now = new Date().getTime(); - var targetTime = this.lastActivityAtTs + MIN_DISPATCH_INTERVAL_MS; + const now = new Date().getTime(); + const targetTime = this.lastActivityAtTs + MIN_DISPATCH_INTERVAL_MS; if (now >= targetTime) { dis.dispatch({ - action: 'user_activity_end' + action: 'user_activity_end', }); this.activityEndTimer = undefined; } else { - this.activityEndTimer = setTimeout( - this._onActivityEndTimer.bind(this), targetTime - now - ); + this.activityEndTimer = setTimeout(this._onActivityEndTimer.bind(this), targetTime - now); } } }