PushRules settings: Put keywords in the right position

This commit is contained in:
manuroe 2016-01-18 16:31:18 +01:00
parent 830160f074
commit ae14210763

View file

@ -249,7 +249,7 @@ module.exports = React.createClass({
var vectorRuleId = event.target.className.split("-")[0]; var vectorRuleId = event.target.className.split("-")[0];
var newPushRuleVectorState = event.target.className.split("-")[1]; var newPushRuleVectorState = event.target.className.split("-")[1];
if ("keywords" === vectorRuleId) { if ("_keywords" === vectorRuleId) {
this._setKeywordsPushRuleVectorState(newPushRuleVectorState) this._setKeywordsPushRuleVectorState(newPushRuleVectorState)
} }
else { else {
@ -729,11 +729,12 @@ module.exports = React.createClass({
self.state.masterPushRule = defaultRules.master[0]; self.state.masterPushRule = defaultRules.master[0];
} }
// Build the rules displayed in Vector UI matrix table // Build the rules displayed in the Vector UI matrix table
self.state.vectorPushRules = []; self.state.vectorPushRules = [];
var vectorRuleIds = [ var vectorRuleIds = [
'im.vector.rule.contains_display_name', 'im.vector.rule.contains_display_name',
'_keywords',
'im.vector.rule.room_one_to_one', 'im.vector.rule.room_one_to_one',
'im.vector.rule.fallback', 'im.vector.rule.fallback',
'im.vector.rule.invite_for_me', 'im.vector.rule.invite_for_me',
@ -744,6 +745,17 @@ module.exports = React.createClass({
var vectorRuleId = vectorRuleIds[i]; var vectorRuleId = vectorRuleIds[i];
var ruleDefinition = VectorPushRulesDefinitions[vectorRuleId]; var ruleDefinition = VectorPushRulesDefinitions[vectorRuleId];
if (vectorRuleId === '_keywords') {
// keywords needs a special handling
// For Vector UI, this is a single global push rule but translated in Matrix,
// it corresponds to all content push rules (stored in self.state.vectorContentRule)
self.state.vectorPushRules.push({
"vectorRuleId": "_keywords",
"description" : (<span>Messages containing <span className="mx_UserNotifSettings_keywords" onClick={ self.onKeywordsClicked }>keywords</span></span>),
"vectorState": self.state.vectorContentRules.vectorState
});
}
else {
var rule = vectorOverridingRules[vectorRuleId]; var rule = vectorOverridingRules[vectorRuleId];
var isHSDefaultRule = false; var isHSDefaultRule = false;
if (!rule) { if (!rule) {
@ -775,15 +787,7 @@ module.exports = React.createClass({
"hsDefaultRule": defaultRules.vector[ruleDefinition.hsDefaultRuleId] "hsDefaultRule": defaultRules.vector[ruleDefinition.hsDefaultRuleId]
}); });
} }
}
// Messages containing keywords
// For Vector UI, this is a single global push rule but translated in Matrix,
// it corresponds to all content push rules (stored in self.state.vectorContentRule)
self.state.vectorPushRules.push({
"vectorRuleId": "keywords",
"description" : (<span>Messages containing <span className="mx_UserNotifSettings_keywords" onClick={ self.onKeywordsClicked }>keywords</span></span>),
"vectorState": self.state.vectorContentRules.vectorState
});
// Build the rules not managed by Vector UI // Build the rules not managed by Vector UI
var otherRulesDescriptions = { var otherRulesDescriptions = {