de-lint Skinner, RoomNotifs

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-07-01 14:28:12 +01:00
parent b8ad0957b2
commit b98c105dcc
No known key found for this signature in database
GPG key ID: 0435A1D4BBD34D64
3 changed files with 15 additions and 28 deletions

View file

@ -140,11 +140,9 @@ src/Resend.js
src/RichText.js src/RichText.js
src/Roles.js src/Roles.js
src/RoomListSorter.js src/RoomListSorter.js
src/RoomNotifs.js
src/Rooms.js src/Rooms.js
src/ScalarAuthClient.js src/ScalarAuthClient.js
src/ScalarMessaging.js src/ScalarMessaging.js
src/Skinner.js
src/stores/LifecycleStore.js src/stores/LifecycleStore.js
src/TabComplete.js src/TabComplete.js
src/TabCompleteEntries.js src/TabCompleteEntries.js

View file

@ -52,7 +52,7 @@ export function getRoomNotifsState(roomId) {
} }
export function setRoomNotifsState(roomId, newState) { export function setRoomNotifsState(roomId, newState) {
if (newState == MUTE) { if (newState === MUTE) {
return setRoomNotifsStateMuted(roomId); return setRoomNotifsStateMuted(roomId);
} else { } else {
return setRoomNotifsStateUnmuted(roomId, newState); return setRoomNotifsStateUnmuted(roomId, newState);
@ -80,11 +80,11 @@ function setRoomNotifsStateMuted(roomId) {
kind: 'event_match', kind: 'event_match',
key: 'room_id', key: 'room_id',
pattern: roomId, pattern: roomId,
} },
], ],
actions: [ actions: [
'dont_notify', 'dont_notify',
] ],
})); }));
return q.all(promises); return q.all(promises);
@ -99,16 +99,16 @@ function setRoomNotifsStateUnmuted(roomId, newState) {
promises.push(cli.deletePushRule('global', 'override', overrideMuteRule.rule_id)); promises.push(cli.deletePushRule('global', 'override', overrideMuteRule.rule_id));
} }
if (newState == 'all_messages') { if (newState === 'all_messages') {
const roomRule = cli.getRoomPushRule('global', roomId); const roomRule = cli.getRoomPushRule('global', roomId);
if (roomRule) { if (roomRule) {
promises.push(cli.deletePushRule('global', 'room', roomRule.rule_id)); promises.push(cli.deletePushRule('global', 'room', roomRule.rule_id));
} }
} else if (newState == 'mentions_only') { } else if (newState === 'mentions_only') {
promises.push(cli.addPushRule('global', 'room', roomId, { promises.push(cli.addPushRule('global', 'room', roomId, {
actions: [ actions: [
'dont_notify', 'dont_notify',
] ],
})); }));
// https://matrix.org/jira/browse/SPEC-400 // https://matrix.org/jira/browse/SPEC-400
promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true)); promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true));
@ -119,8 +119,8 @@ function setRoomNotifsStateUnmuted(roomId, newState) {
{ {
set_tweak: 'sound', set_tweak: 'sound',
value: 'default', value: 'default',
} },
] ],
})); }));
// https://matrix.org/jira/browse/SPEC-400 // https://matrix.org/jira/browse/SPEC-400
promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true)); promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true));
@ -145,20 +145,10 @@ function isRuleForRoom(roomId, rule) {
return false; return false;
} }
const cond = rule.conditions[0]; const cond = rule.conditions[0];
if ( return (cond.kind === 'event_match' && cond.key === 'room_id' && cond.pattern === roomId);
cond.kind == 'event_match' &&
cond.key == 'room_id' &&
cond.pattern == roomId
) {
return true;
}
return false;
} }
function isMuteRule(rule) { function isMuteRule(rule) {
return ( return (rule.actions.length === 1 && rule.actions[0] === 'dont_notify');
rule.actions.length == 1 &&
rule.actions[0] == 'dont_notify'
);
} }

View file

@ -51,19 +51,18 @@ class Skinner {
if (this.components !== null) { if (this.components !== null) {
throw new Error( throw new Error(
"Attempted to load a skin while a skin is already loaded"+ "Attempted to load a skin while a skin is already loaded"+
"If you want to change the active skin, call resetSkin first" "If you want to change the active skin, call resetSkin first");
);
} }
this.components = {}; this.components = {};
var compKeys = Object.keys(skinObject.components); const compKeys = Object.keys(skinObject.components);
for (var i = 0; i < compKeys.length; ++i) { for (let i = 0; i < compKeys.length; ++i) {
var comp = skinObject.components[compKeys[i]]; const comp = skinObject.components[compKeys[i]];
this.addComponent(compKeys[i], comp); this.addComponent(compKeys[i], comp);
} }
} }
addComponent(name, comp) { addComponent(name, comp) {
var slot = name; let slot = name;
if (comp.replaces !== undefined) { if (comp.replaces !== undefined) {
if (comp.replaces.indexOf('.') > -1) { if (comp.replaces.indexOf('.') > -1) {
slot = comp.replaces; slot = comp.replaces;