Fix lint errors in Notifications.js
Signed-off-by: Aaron Raimist <aaron@raim.ist>
This commit is contained in:
parent
d452dd2b74
commit
1287d9c49b
1 changed files with 63 additions and 75 deletions
|
@ -26,7 +26,7 @@ import {
|
||||||
NotificationUtils,
|
NotificationUtils,
|
||||||
VectorPushRulesDefinitions,
|
VectorPushRulesDefinitions,
|
||||||
PushRuleVectorState,
|
PushRuleVectorState,
|
||||||
ContentRules
|
ContentRules,
|
||||||
} from '../../../notifications';
|
} from '../../../notifications';
|
||||||
|
|
||||||
// TODO: this "view" component still has far too much application logic in it,
|
// TODO: this "view" component still has far too much application logic in it,
|
||||||
|
@ -47,7 +47,7 @@ const LEGACY_RULES = {
|
||||||
"im.vector.rule.room_message": ".m.rule.message",
|
"im.vector.rule.room_message": ".m.rule.message",
|
||||||
"im.vector.rule.invite_for_me": ".m.rule.invite_for_me",
|
"im.vector.rule.invite_for_me": ".m.rule.invite_for_me",
|
||||||
"im.vector.rule.call": ".m.rule.call",
|
"im.vector.rule.call": ".m.rule.call",
|
||||||
"im.vector.rule.notices": ".m.rule.suppress_notices"
|
"im.vector.rule.notices": ".m.rule.suppress_notices",
|
||||||
};
|
};
|
||||||
|
|
||||||
function portLegacyActions(actions) {
|
function portLegacyActions(actions) {
|
||||||
|
@ -67,7 +67,7 @@ module.exports = React.createClass({
|
||||||
phases: {
|
phases: {
|
||||||
LOADING: "LOADING", // The component is loading or sending data to the hs
|
LOADING: "LOADING", // The component is loading or sending data to the hs
|
||||||
DISPLAY: "DISPLAY", // The component is ready and display data
|
DISPLAY: "DISPLAY", // The component is ready and display data
|
||||||
ERROR: "ERROR" // There was an error
|
ERROR: "ERROR", // There was an error
|
||||||
},
|
},
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
@ -79,7 +79,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
threepids: []
|
threepids: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -90,10 +90,10 @@ module.exports = React.createClass({
|
||||||
vectorPushRules: [], // HS default push rules displayed in Vector UI
|
vectorPushRules: [], // HS default push rules displayed in Vector UI
|
||||||
vectorContentRules: { // Keyword push rules displayed in Vector UI
|
vectorContentRules: { // Keyword push rules displayed in Vector UI
|
||||||
vectorState: PushRuleVectorState.ON,
|
vectorState: PushRuleVectorState.ON,
|
||||||
rules: []
|
rules: [],
|
||||||
},
|
},
|
||||||
externalPushRules: [], // Push rules (except content rule) that have been defined outside Vector UI
|
externalPushRules: [], // Push rules (except content rule) that have been defined outside Vector UI
|
||||||
externalContentRules: [] // Keyword push rules that have been defined outside Vector UI
|
externalContentRules: [], // Keyword push rules that have been defined outside Vector UI
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ module.exports = React.createClass({
|
||||||
onEnableNotificationsChange: function(event) {
|
onEnableNotificationsChange: function(event) {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.setState({
|
this.setState({
|
||||||
phase: this.phases.LOADING
|
phase: this.phases.LOADING,
|
||||||
});
|
});
|
||||||
|
|
||||||
MatrixClientPeg.get().setPushRuleEnabled('global', self.state.masterPushRule.kind, self.state.masterPushRule.rule_id, !event.target.checked).done(function() {
|
MatrixClientPeg.get().setPushRuleEnabled('global', self.state.masterPushRule.kind, self.state.masterPushRule.rule_id, !event.target.checked).done(function() {
|
||||||
|
@ -145,7 +145,7 @@ module.exports = React.createClass({
|
||||||
onEnableEmailNotificationsChange: function(address, event) {
|
onEnableEmailNotificationsChange: function(address, event) {
|
||||||
let emailPusherPromise;
|
let emailPusherPromise;
|
||||||
if (event.target.checked) {
|
if (event.target.checked) {
|
||||||
const data = {}
|
const data = {};
|
||||||
data['brand'] = this.props.brand || 'Riot';
|
data['brand'] = this.props.brand || 'Riot';
|
||||||
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
|
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
|
||||||
} else {
|
} else {
|
||||||
|
@ -170,9 +170,8 @@ module.exports = React.createClass({
|
||||||
const newPushRuleVectorState = event.target.className.split("-")[1];
|
const newPushRuleVectorState = event.target.className.split("-")[1];
|
||||||
|
|
||||||
if ("_keywords" === vectorRuleId) {
|
if ("_keywords" === vectorRuleId) {
|
||||||
this._setKeywordsPushRuleVectorState(newPushRuleVectorState)
|
this._setKeywordsPushRuleVectorState(newPushRuleVectorState);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const rule = this.getRule(vectorRuleId);
|
const rule = this.getRule(vectorRuleId);
|
||||||
if (rule) {
|
if (rule) {
|
||||||
this._setPushRuleVectorState(rule, newPushRuleVectorState);
|
this._setPushRuleVectorState(rule, newPushRuleVectorState);
|
||||||
|
@ -185,7 +184,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// Compute the keywords list to display
|
// Compute the keywords list to display
|
||||||
let keywords = [];
|
let keywords = [];
|
||||||
for (let i in this.state.vectorContentRules.rules) {
|
for (const i in this.state.vectorContentRules.rules) {
|
||||||
const rule = this.state.vectorContentRules.rules[i];
|
const rule = this.state.vectorContentRules.rules[i];
|
||||||
keywords.push(rule.pattern);
|
keywords.push(rule.pattern);
|
||||||
}
|
}
|
||||||
|
@ -195,8 +194,7 @@ module.exports = React.createClass({
|
||||||
keywords.sort();
|
keywords.sort();
|
||||||
|
|
||||||
keywords = keywords.join(", ");
|
keywords = keywords.join(", ");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
keywords = "";
|
keywords = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,10 +205,9 @@ module.exports = React.createClass({
|
||||||
button: _t('OK'),
|
button: _t('OK'),
|
||||||
value: keywords,
|
value: keywords,
|
||||||
onFinished: function onFinished(should_leave, newValue) {
|
onFinished: function onFinished(should_leave, newValue) {
|
||||||
|
|
||||||
if (should_leave && newValue !== keywords) {
|
if (should_leave && newValue !== keywords) {
|
||||||
let newKeywords = newValue.split(',');
|
let newKeywords = newValue.split(',');
|
||||||
for (let i in newKeywords) {
|
for (const i in newKeywords) {
|
||||||
newKeywords[i] = newKeywords[i].trim();
|
newKeywords[i] = newKeywords[i].trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,12 +221,12 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
self._setKeywords(newKeywords);
|
self._setKeywords(newKeywords);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getRule: function(vectorRuleId) {
|
getRule: function(vectorRuleId) {
|
||||||
for (let i in this.state.vectorPushRules) {
|
for (const i in this.state.vectorPushRules) {
|
||||||
const rule = this.state.vectorPushRules[i];
|
const rule = this.state.vectorPushRules[i];
|
||||||
if (rule.vectorRuleId === vectorRuleId) {
|
if (rule.vectorRuleId === vectorRuleId) {
|
||||||
return rule;
|
return rule;
|
||||||
|
@ -239,9 +236,8 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
_setPushRuleVectorState: function(rule, newPushRuleVectorState) {
|
_setPushRuleVectorState: function(rule, newPushRuleVectorState) {
|
||||||
if (rule && rule.vectorState !== newPushRuleVectorState) {
|
if (rule && rule.vectorState !== newPushRuleVectorState) {
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
phase: this.phases.LOADING
|
phase: this.phases.LOADING,
|
||||||
});
|
});
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
@ -255,8 +251,7 @@ module.exports = React.createClass({
|
||||||
if (!actions) {
|
if (!actions) {
|
||||||
// The new state corresponds to disabling the rule.
|
// The new state corresponds to disabling the rule.
|
||||||
deferreds.push(cli.setPushRuleEnabled('global', rule.rule.kind, rule.rule.rule_id, false));
|
deferreds.push(cli.setPushRuleEnabled('global', rule.rule.kind, rule.rule.rule_id, false));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// The new state corresponds to enabling the rule and setting specific actions
|
// The new state corresponds to enabling the rule and setting specific actions
|
||||||
deferreds.push(this._updatePushRuleActions(rule.rule, actions, true));
|
deferreds.push(this._updatePushRuleActions(rule.rule, actions, true));
|
||||||
}
|
}
|
||||||
|
@ -270,7 +265,7 @@ module.exports = React.createClass({
|
||||||
Modal.createTrackedDialog('Failed to change settings', '', ErrorDialog, {
|
Modal.createTrackedDialog('Failed to change settings', '', ErrorDialog, {
|
||||||
title: _t('Failed to change settings'),
|
title: _t('Failed to change settings'),
|
||||||
description: ((error && error.message) ? error.message : _t('Operation failed')),
|
description: ((error && error.message) ? error.message : _t('Operation failed')),
|
||||||
onFinished: self._refreshFromServer
|
onFinished: self._refreshFromServer,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -287,12 +282,12 @@ module.exports = React.createClass({
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
phase: this.phases.LOADING
|
phase: this.phases.LOADING,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update all rules in self.state.vectorContentRules
|
// Update all rules in self.state.vectorContentRules
|
||||||
const deferreds = [];
|
const deferreds = [];
|
||||||
for (let i in this.state.vectorContentRules.rules) {
|
for (const i in this.state.vectorContentRules.rules) {
|
||||||
const rule = this.state.vectorContentRules.rules[i];
|
const rule = this.state.vectorContentRules.rules[i];
|
||||||
|
|
||||||
let enabled, actions;
|
let enabled, actions;
|
||||||
|
@ -326,8 +321,7 @@ module.exports = React.createClass({
|
||||||
// Note that the workaround in _updatePushRuleActions will automatically
|
// Note that the workaround in _updatePushRuleActions will automatically
|
||||||
// enable the rule
|
// enable the rule
|
||||||
deferreds.push(this._updatePushRuleActions(rule, actions, enabled));
|
deferreds.push(this._updatePushRuleActions(rule, actions, enabled));
|
||||||
}
|
} else if (enabled != undefined) {
|
||||||
else if (enabled != undefined) {
|
|
||||||
deferreds.push(cli.setPushRuleEnabled('global', rule.kind, rule.rule_id, enabled));
|
deferreds.push(cli.setPushRuleEnabled('global', rule.kind, rule.rule_id, enabled));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,14 +334,14 @@ module.exports = React.createClass({
|
||||||
Modal.createTrackedDialog('Can\'t update user notifcation settings', '', ErrorDialog, {
|
Modal.createTrackedDialog('Can\'t update user notifcation settings', '', ErrorDialog, {
|
||||||
title: _t('Can\'t update user notification settings'),
|
title: _t('Can\'t update user notification settings'),
|
||||||
description: ((error && error.message) ? error.message : _t('Operation failed')),
|
description: ((error && error.message) ? error.message : _t('Operation failed')),
|
||||||
onFinished: self._refreshFromServer
|
onFinished: self._refreshFromServer,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_setKeywords: function(newKeywords) {
|
_setKeywords: function(newKeywords) {
|
||||||
this.setState({
|
this.setState({
|
||||||
phase: this.phases.LOADING
|
phase: this.phases.LOADING,
|
||||||
});
|
});
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
@ -356,7 +350,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// Remove per-word push rules of keywords that are no more in the list
|
// Remove per-word push rules of keywords that are no more in the list
|
||||||
const vectorContentRulesPatterns = [];
|
const vectorContentRulesPatterns = [];
|
||||||
for (let i in self.state.vectorContentRules.rules) {
|
for (const i in self.state.vectorContentRules.rules) {
|
||||||
const rule = self.state.vectorContentRules.rules[i];
|
const rule = self.state.vectorContentRules.rules[i];
|
||||||
|
|
||||||
vectorContentRulesPatterns.push(rule.pattern);
|
vectorContentRulesPatterns.push(rule.pattern);
|
||||||
|
@ -368,7 +362,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// If the keyword is part of `externalContentRules`, remove the rule
|
// If the keyword is part of `externalContentRules`, remove the rule
|
||||||
// before recreating it in the right Vector path
|
// before recreating it in the right Vector path
|
||||||
for (let i in self.state.externalContentRules) {
|
for (const i in self.state.externalContentRules) {
|
||||||
const rule = self.state.externalContentRules[i];
|
const rule = self.state.externalContentRules[i];
|
||||||
|
|
||||||
if (newKeywords.indexOf(rule.pattern) >= 0) {
|
if (newKeywords.indexOf(rule.pattern) >= 0) {
|
||||||
|
@ -382,9 +376,9 @@ module.exports = React.createClass({
|
||||||
Modal.createTrackedDialog('Failed to update keywords', '', ErrorDialog, {
|
Modal.createTrackedDialog('Failed to update keywords', '', ErrorDialog, {
|
||||||
title: _t('Failed to update keywords'),
|
title: _t('Failed to update keywords'),
|
||||||
description: ((error && error.message) ? error.message : _t('Operation failed')),
|
description: ((error && error.message) ? error.message : _t('Operation failed')),
|
||||||
onFinished: self._refreshFromServer
|
onFinished: self._refreshFromServer,
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
// Then, add the new ones
|
// Then, add the new ones
|
||||||
Promise.all(removeDeferreds).done(function(resps) {
|
Promise.all(removeDeferreds).done(function(resps) {
|
||||||
|
@ -398,14 +392,13 @@ module.exports = React.createClass({
|
||||||
// Thus, this new rule will join the 'vectorContentRules' set.
|
// Thus, this new rule will join the 'vectorContentRules' set.
|
||||||
if (self.state.vectorContentRules.rules.length) {
|
if (self.state.vectorContentRules.rules.length) {
|
||||||
pushRuleVectorStateKind = PushRuleVectorState.contentRuleVectorStateKind(self.state.vectorContentRules.rules[0]);
|
pushRuleVectorStateKind = PushRuleVectorState.contentRuleVectorStateKind(self.state.vectorContentRules.rules[0]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// ON is default
|
// ON is default
|
||||||
pushRuleVectorStateKind = PushRuleVectorState.ON;
|
pushRuleVectorStateKind = PushRuleVectorState.ON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i in newKeywords) {
|
for (const i in newKeywords) {
|
||||||
const keyword = newKeywords[i];
|
const keyword = newKeywords[i];
|
||||||
|
|
||||||
if (vectorContentRulesPatterns.indexOf(keyword) < 0) {
|
if (vectorContentRulesPatterns.indexOf(keyword) < 0) {
|
||||||
|
@ -413,13 +406,12 @@ module.exports = React.createClass({
|
||||||
deferreds.push(cli.addPushRule
|
deferreds.push(cli.addPushRule
|
||||||
('global', 'content', keyword, {
|
('global', 'content', keyword, {
|
||||||
actions: PushRuleVectorState.actionsFor(pushRuleVectorStateKind),
|
actions: PushRuleVectorState.actionsFor(pushRuleVectorStateKind),
|
||||||
pattern: keyword
|
pattern: keyword,
|
||||||
}));
|
}));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
deferreds.push(self._addDisabledPushRule('global', 'content', keyword, {
|
deferreds.push(self._addDisabledPushRule('global', 'content', keyword, {
|
||||||
actions: PushRuleVectorState.actionsFor(pushRuleVectorStateKind),
|
actions: PushRuleVectorState.actionsFor(pushRuleVectorStateKind),
|
||||||
pattern: keyword
|
pattern: keyword,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,7 +427,7 @@ module.exports = React.createClass({
|
||||||
_addDisabledPushRule: function(scope, kind, ruleId, body) {
|
_addDisabledPushRule: function(scope, kind, ruleId, body) {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
return cli.addPushRule(scope, kind, ruleId, body).then(() =>
|
return cli.addPushRule(scope, kind, ruleId, body).then(() =>
|
||||||
cli.setPushRuleEnabled(scope, kind, ruleId, false)
|
cli.setPushRuleEnabled(scope, kind, ruleId, false),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -446,7 +438,7 @@ module.exports = React.createClass({
|
||||||
const needsUpdate = [];
|
const needsUpdate = [];
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
|
|
||||||
for (let kind in rulesets.global) {
|
for (const kind in rulesets.global) {
|
||||||
const ruleset = rulesets.global[kind];
|
const ruleset = rulesets.global[kind];
|
||||||
for (let i = 0; i < ruleset.length; ++i) {
|
for (let i = 0; i < ruleset.length; ++i) {
|
||||||
const rule = ruleset[i];
|
const rule = ruleset[i];
|
||||||
|
@ -454,9 +446,9 @@ module.exports = React.createClass({
|
||||||
console.log("Porting legacy rule", rule);
|
console.log("Porting legacy rule", rule);
|
||||||
needsUpdate.push( function(kind, rule) {
|
needsUpdate.push( function(kind, rule) {
|
||||||
return cli.setPushRuleActions(
|
return cli.setPushRuleActions(
|
||||||
'global', kind, LEGACY_RULES[rule.rule_id], portLegacyActions(rule.actions)
|
'global', kind, LEGACY_RULES[rule.rule_id], portLegacyActions(rule.actions),
|
||||||
).then(() =>
|
).then(() =>
|
||||||
cli.deletePushRule('global', kind, rule.rule_id)
|
cli.deletePushRule('global', kind, rule.rule_id),
|
||||||
).catch( (e) => {
|
).catch( (e) => {
|
||||||
console.warn(`Error when porting legacy rule: ${e}`);
|
console.warn(`Error when porting legacy rule: ${e}`);
|
||||||
});
|
});
|
||||||
|
@ -469,7 +461,7 @@ module.exports = React.createClass({
|
||||||
// If some of the rules need to be ported then wait for the porting
|
// If some of the rules need to be ported then wait for the porting
|
||||||
// to happen and then fetch the rules again.
|
// to happen and then fetch the rules again.
|
||||||
return Promise.all(needsUpdate).then(() =>
|
return Promise.all(needsUpdate).then(() =>
|
||||||
cli.getPushRules()
|
cli.getPushRules(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise return the rules that we already have.
|
// Otherwise return the rules that we already have.
|
||||||
|
@ -480,7 +472,6 @@ module.exports = React.createClass({
|
||||||
_refreshFromServer: function() {
|
_refreshFromServer: function() {
|
||||||
const self = this;
|
const self = this;
|
||||||
const pushRulesPromise = MatrixClientPeg.get().getPushRules().then(self._portRulesToNewAPI).then(function(rulesets) {
|
const pushRulesPromise = MatrixClientPeg.get().getPushRules().then(self._portRulesToNewAPI).then(function(rulesets) {
|
||||||
|
|
||||||
/// XXX seriously? wtf is this?
|
/// XXX seriously? wtf is this?
|
||||||
MatrixClientPeg.get().pushRules = rulesets;
|
MatrixClientPeg.get().pushRules = rulesets;
|
||||||
|
|
||||||
|
@ -497,7 +488,7 @@ module.exports = React.createClass({
|
||||||
'.m.rule.invite_for_me': 'vector',
|
'.m.rule.invite_for_me': 'vector',
|
||||||
//'.m.rule.member_event': 'vector',
|
//'.m.rule.member_event': 'vector',
|
||||||
'.m.rule.call': 'vector',
|
'.m.rule.call': 'vector',
|
||||||
'.m.rule.suppress_notices': 'vector'
|
'.m.rule.suppress_notices': 'vector',
|
||||||
|
|
||||||
// Others go to others
|
// Others go to others
|
||||||
};
|
};
|
||||||
|
@ -505,7 +496,7 @@ module.exports = React.createClass({
|
||||||
// HS default rules
|
// HS default rules
|
||||||
const defaultRules = {master: [], vector: {}, others: []};
|
const defaultRules = {master: [], vector: {}, others: []};
|
||||||
|
|
||||||
for (let kind in rulesets.global) {
|
for (const kind in rulesets.global) {
|
||||||
for (let i = 0; i < Object.keys(rulesets.global[kind]).length; ++i) {
|
for (let i = 0; i < Object.keys(rulesets.global[kind]).length; ++i) {
|
||||||
const r = rulesets.global[kind][i];
|
const r = rulesets.global[kind][i];
|
||||||
const cat = rule_categories[r.rule_id];
|
const cat = rule_categories[r.rule_id];
|
||||||
|
@ -514,11 +505,9 @@ module.exports = React.createClass({
|
||||||
if (r.rule_id[0] === '.') {
|
if (r.rule_id[0] === '.') {
|
||||||
if (cat === 'vector') {
|
if (cat === 'vector') {
|
||||||
defaultRules.vector[r.rule_id] = r;
|
defaultRules.vector[r.rule_id] = r;
|
||||||
}
|
} else if (cat === 'master') {
|
||||||
else if (cat === 'master') {
|
|
||||||
defaultRules.master.push(r);
|
defaultRules.master.push(r);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
defaultRules['others'].push(r);
|
defaultRules['others'].push(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,9 +540,9 @@ module.exports = React.createClass({
|
||||||
'.m.rule.invite_for_me',
|
'.m.rule.invite_for_me',
|
||||||
//'im.vector.rule.member_event',
|
//'im.vector.rule.member_event',
|
||||||
'.m.rule.call',
|
'.m.rule.call',
|
||||||
'.m.rule.suppress_notices'
|
'.m.rule.suppress_notices',
|
||||||
];
|
];
|
||||||
for (let i in vectorRuleIds) {
|
for (const i in vectorRuleIds) {
|
||||||
const vectorRuleId = vectorRuleIds[i];
|
const vectorRuleId = vectorRuleIds[i];
|
||||||
|
|
||||||
if (vectorRuleId === '_keywords') {
|
if (vectorRuleId === '_keywords') {
|
||||||
|
@ -567,15 +556,14 @@ module.exports = React.createClass({
|
||||||
{ _t('Messages containing <span>keywords</span>',
|
{ _t('Messages containing <span>keywords</span>',
|
||||||
{},
|
{},
|
||||||
{ 'span': (sub) =>
|
{ 'span': (sub) =>
|
||||||
<span className="mx_UserNotifSettings_keywords" onClick={ self.onKeywordsClicked }>{sub}</span>
|
<span className="mx_UserNotifSettings_keywords" onClick={ self.onKeywordsClicked }>{sub}</span>,
|
||||||
},
|
},
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
"vectorState": self.state.vectorContentRules.vectorState
|
"vectorState": self.state.vectorContentRules.vectorState,
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const ruleDefinition = VectorPushRulesDefinitions[vectorRuleId];
|
const ruleDefinition = VectorPushRulesDefinitions[vectorRuleId];
|
||||||
const rule = defaultRules.vector[vectorRuleId];
|
const rule = defaultRules.vector[vectorRuleId];
|
||||||
|
|
||||||
|
@ -604,7 +592,7 @@ module.exports = React.createClass({
|
||||||
'.m.rule.fallback': _t('Notify me for anything else'),
|
'.m.rule.fallback': _t('Notify me for anything else'),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i in defaultRules.others) {
|
for (const i in defaultRules.others) {
|
||||||
const rule = defaultRules.others[i];
|
const rule = defaultRules.others[i];
|
||||||
const ruleDescription = otherRulesDescriptions[rule.rule_id];
|
const ruleDescription = otherRulesDescriptions[rule.rule_id];
|
||||||
|
|
||||||
|
@ -622,12 +610,12 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
Promise.all([pushRulesPromise, pushersPromise]).then(function() {
|
Promise.all([pushRulesPromise, pushersPromise]).then(function() {
|
||||||
self.setState({
|
self.setState({
|
||||||
phase: self.phases.DISPLAY
|
phase: self.phases.DISPLAY,
|
||||||
});
|
});
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
self.setState({
|
self.setState({
|
||||||
phase: self.phases.ERROR
|
phase: self.phases.ERROR,
|
||||||
});
|
});
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
// actually explicitly update our state having been deep-manipulating it
|
// actually explicitly update our state having been deep-manipulating it
|
||||||
|
@ -645,12 +633,12 @@ module.exports = React.createClass({
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
|
|
||||||
return cli.setPushRuleActions(
|
return cli.setPushRuleActions(
|
||||||
'global', rule.kind, rule.rule_id, actions
|
'global', rule.kind, rule.rule_id, actions,
|
||||||
).then( function() {
|
).then( function() {
|
||||||
// Then, if requested, enabled or disabled the rule
|
// Then, if requested, enabled or disabled the rule
|
||||||
if (undefined != enabled) {
|
if (undefined != enabled) {
|
||||||
return cli.setPushRuleEnabled(
|
return cli.setPushRuleEnabled(
|
||||||
'global', rule.kind, rule.rule_id, enabled
|
'global', rule.kind, rule.rule_id, enabled,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -689,7 +677,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
renderNotifRulesTableRows: function() {
|
renderNotifRulesTableRows: function() {
|
||||||
const rows = [];
|
const rows = [];
|
||||||
for (let i in this.state.vectorPushRules) {
|
for (const i in this.state.vectorPushRules) {
|
||||||
const rule = this.state.vectorPushRules[i];
|
const rule = this.state.vectorPushRules[i];
|
||||||
//console.log("rendering: " + rule.description + ", " + rule.vectorRuleId + ", " + rule.vectorState);
|
//console.log("rendering: " + rule.description + ", " + rule.vectorRuleId + ", " + rule.vectorState);
|
||||||
rows.push(this.renderNotifRulesTableRow(rule.description, rule.vectorRuleId, rule.vectorState));
|
rows.push(this.renderNotifRulesTableRow(rule.description, rule.vectorRuleId, rule.vectorState));
|
||||||
|
@ -769,20 +757,20 @@ module.exports = React.createClass({
|
||||||
// This only supports the first email address in your profile for now
|
// This only supports the first email address in your profile for now
|
||||||
emailNotificationsRow = this.emailNotificationsRow(
|
emailNotificationsRow = this.emailNotificationsRow(
|
||||||
emailThreepids[0].address,
|
emailThreepids[0].address,
|
||||||
`${_t('Enable email notifications')} (${emailThreepids[0].address})`
|
`${_t('Enable email notifications')} (${emailThreepids[0].address})`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build external push rules
|
// Build external push rules
|
||||||
const externalRules = [];
|
const externalRules = [];
|
||||||
for (let i in this.state.externalPushRules) {
|
for (const i in this.state.externalPushRules) {
|
||||||
const rule = this.state.externalPushRules[i];
|
const rule = this.state.externalPushRules[i];
|
||||||
externalRules.push(<li>{ _t(rule.description) }</li>);
|
externalRules.push(<li>{ _t(rule.description) }</li>);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show keywords not displayed by the vector UI as a single external push rule
|
// Show keywords not displayed by the vector UI as a single external push rule
|
||||||
let externalKeywords = [];
|
let externalKeywords = [];
|
||||||
for (let i in this.state.externalContentRules) {
|
for (const i in this.state.externalContentRules) {
|
||||||
const rule = this.state.externalContentRules[i];
|
const rule = this.state.externalContentRules[i];
|
||||||
externalKeywords.push(rule.pattern);
|
externalKeywords.push(rule.pattern);
|
||||||
}
|
}
|
||||||
|
@ -793,7 +781,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
let devicesSection;
|
let devicesSection;
|
||||||
if (this.state.pushers === undefined) {
|
if (this.state.pushers === undefined) {
|
||||||
devicesSection = <div className="error">{ _t('Unable to fetch notification target list') }</div>
|
devicesSection = <div className="error">{ _t('Unable to fetch notification target list') }</div>;
|
||||||
} else if (this.state.pushers.length == 0) {
|
} else if (this.state.pushers.length == 0) {
|
||||||
devicesSection = null;
|
devicesSection = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -915,5 +903,5 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue