de-lint Resend, RoomListSorter, UserActivity

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-07-01 14:50:22 +01:00
parent 8bf13f8f48
commit 661a0f3956
No known key found for this signature in database
GPG key ID: 0435A1D4BBD34D64
5 changed files with 21 additions and 34 deletions

View file

@ -129,10 +129,8 @@ src/Notifier.js
src/PlatformPeg.js src/PlatformPeg.js
src/Presence.js src/Presence.js
src/ratelimitedfunc.js src/ratelimitedfunc.js
src/Resend.js
src/RichText.js src/RichText.js
src/Roles.js src/Roles.js
src/RoomListSorter.js
src/Rooms.js src/Rooms.js
src/ScalarAuthClient.js src/ScalarAuthClient.js
src/ScalarMessaging.js src/ScalarMessaging.js
@ -142,7 +140,6 @@ src/TextForEvent.js
src/Tinter.js src/Tinter.js
src/UiEffects.js src/UiEffects.js
src/Unread.js src/Unread.js
src/UserActivity.js
src/utils/DecryptFile.js src/utils/DecryptFile.js
src/utils/DMRoomMap.js src/utils/DMRoomMap.js
src/utils/FormattingUtils.js src/utils/FormattingUtils.js

View file

@ -14,10 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
var MatrixClientPeg = require('./MatrixClientPeg'); import MatrixClientPeg from './MatrixClientPeg';
var dis = require('./dispatcher'); import dis from './dispatcher';
var sdk = require('./index');
var Modal = require('./Modal');
import { EventStatus } from 'matrix-js-sdk'; import { EventStatus } from 'matrix-js-sdk';
module.exports = { module.exports = {
@ -37,12 +35,10 @@ module.exports = {
}, },
resend: function(event) { resend: function(event) {
const room = MatrixClientPeg.get().getRoom(event.getRoomId()); const room = MatrixClientPeg.get().getRoom(event.getRoomId());
MatrixClientPeg.get().resendEvent( MatrixClientPeg.get().resendEvent(event, room).done(function(res) {
event, room
).done(function(res) {
dis.dispatch({ dis.dispatch({
action: 'message_sent', action: 'message_sent',
event: event event: event,
}); });
}, function(err) { }, function(err) {
// XXX: temporary logging to try to diagnose // XXX: temporary logging to try to diagnose
@ -58,7 +54,7 @@ module.exports = {
dis.dispatch({ dis.dispatch({
action: 'message_send_failed', action: 'message_send_failed',
event: event event: event,
}); });
}); });
}, },
@ -66,7 +62,7 @@ module.exports = {
MatrixClientPeg.get().cancelPendingEvent(event); MatrixClientPeg.get().cancelPendingEvent(event);
dis.dispatch({ dis.dispatch({
action: 'message_send_cancelled', action: 'message_send_cancelled',
event: event event: event,
}); });
}, },
}; };

View file

@ -19,7 +19,7 @@ export function levelRoleMap() {
return { return {
undefined: _t('Default'), undefined: _t('Default'),
0: _t('User'), 0: _t('User'),
50: _t('Moderator'), 50: _t('Moderator'),
100: _t('Admin'), 100: _t('Admin'),
}; };
} }

View file

@ -19,8 +19,7 @@ limitations under the License.
function tsOfNewestEvent(room) { function tsOfNewestEvent(room) {
if (room.timeline.length) { if (room.timeline.length) {
return room.timeline[room.timeline.length - 1].getTs(); return room.timeline[room.timeline.length - 1].getTs();
} } else {
else {
return Number.MAX_SAFE_INTEGER; return Number.MAX_SAFE_INTEGER;
} }
} }
@ -32,5 +31,5 @@ function mostRecentActivityFirst(roomList) {
} }
module.exports = { module.exports = {
mostRecentActivityFirst: mostRecentActivityFirst mostRecentActivityFirst,
}; };

View file

@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
var dis = require("./dispatcher"); import dis from './dispatcher';
var MIN_DISPATCH_INTERVAL_MS = 500; const MIN_DISPATCH_INTERVAL_MS = 500;
var CURRENTLY_ACTIVE_THRESHOLD_MS = 2000; const CURRENTLY_ACTIVE_THRESHOLD_MS = 2000;
/** /**
* This class watches for user activity (moving the mouse or pressing a key) * 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 * Return true if there has been user activity very recently
* (ie. within a few seconds) * (ie. within a few seconds)
* @returns {boolean} true if user is currently/very recently active
*/ */
userCurrentlyActive() { userCurrentlyActive() {
return this.lastActivityAtTs > new Date().getTime() - CURRENTLY_ACTIVE_THRESHOLD_MS; return this.lastActivityAtTs > new Date().getTime() - CURRENTLY_ACTIVE_THRESHOLD_MS;
} }
_onUserActivity(event) { _onUserActivity(event) {
if (event.screenX && event.type == "mousemove") { if (event.screenX && event.type === "mousemove") {
if (event.screenX === this.lastScreenX && if (event.screenX === this.lastScreenX && event.screenY === this.lastScreenY) {
event.screenY === this.lastScreenY)
{
// mouse hasn't actually moved // mouse hasn't actually moved
return; return;
} }
@ -79,28 +78,24 @@ class UserActivity {
if (this.lastDispatchAtTs < this.lastActivityAtTs - MIN_DISPATCH_INTERVAL_MS) { if (this.lastDispatchAtTs < this.lastActivityAtTs - MIN_DISPATCH_INTERVAL_MS) {
this.lastDispatchAtTs = this.lastActivityAtTs; this.lastDispatchAtTs = this.lastActivityAtTs;
dis.dispatch({ dis.dispatch({
action: 'user_activity' action: 'user_activity',
}); });
if (!this.activityEndTimer) { if (!this.activityEndTimer) {
this.activityEndTimer = setTimeout( this.activityEndTimer = setTimeout(this._onActivityEndTimer.bind(this), MIN_DISPATCH_INTERVAL_MS);
this._onActivityEndTimer.bind(this), MIN_DISPATCH_INTERVAL_MS
);
} }
} }
} }
_onActivityEndTimer() { _onActivityEndTimer() {
var now = new Date().getTime(); const now = new Date().getTime();
var targetTime = this.lastActivityAtTs + MIN_DISPATCH_INTERVAL_MS; const targetTime = this.lastActivityAtTs + MIN_DISPATCH_INTERVAL_MS;
if (now >= targetTime) { if (now >= targetTime) {
dis.dispatch({ dis.dispatch({
action: 'user_activity_end' action: 'user_activity_end',
}); });
this.activityEndTimer = undefined; this.activityEndTimer = undefined;
} else { } else {
this.activityEndTimer = setTimeout( this.activityEndTimer = setTimeout(this._onActivityEndTimer.bind(this), targetTime - now);
this._onActivityEndTimer.bind(this), targetTime - now
);
} }
} }
} }