mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
PushRules settings: Fixed triage of matrix content rules into the unique Vector rule
This commit is contained in:
parent
7f95362dd2
commit
b9080c770d
@ -158,7 +158,7 @@ module.exports = React.createClass({
|
|||||||
// HS default rules
|
// HS default rules
|
||||||
var defaultRules = {master: [], vector: {}, additional: [], fallthrough: [], suppression: []};
|
var defaultRules = {master: [], vector: {}, additional: [], fallthrough: [], suppression: []};
|
||||||
// Content/keyword rules
|
// Content/keyword rules
|
||||||
var contentRules = {on: [], strong: [], off: [], other: []};
|
var contentRules = {on: [], on_but_disabled:[], strong: [], strong_but_disabled: [], other: []};
|
||||||
|
|
||||||
for (var kind in rulesets.global) {
|
for (var kind in rulesets.global) {
|
||||||
for (var i = 0; i < Object.keys(rulesets.global[kind]).length; ++i) {
|
for (var i = 0; i < Object.keys(rulesets.global[kind]).length; ++i) {
|
||||||
@ -180,7 +180,6 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (kind === 'content') {
|
else if (kind === 'content') {
|
||||||
if (r.enabled) {
|
|
||||||
// Count tweaks to determine if it is a ON or STRONG rule
|
// Count tweaks to determine if it is a ON or STRONG rule
|
||||||
var tweaks = 0;
|
var tweaks = 0;
|
||||||
for (var j in r.actions) {
|
for (var j in r.actions) {
|
||||||
@ -193,20 +192,26 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
switch (tweaks) {
|
switch (tweaks) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (r.enabled) {
|
||||||
contentRules.on.push(r);
|
contentRules.on.push(r);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
contentRules.on_but_disabled.push(r);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
if (r.enabled) {
|
||||||
contentRules.strong.push(r);
|
contentRules.strong.push(r);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
contentRules.strong_but_disabled.push(r);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
contentRules.other.push(r);
|
contentRules.other.push(r);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
contentRules.off.push(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,21 +233,31 @@ module.exports = React.createClass({
|
|||||||
state: PushRuleState.STRONG,
|
state: PushRuleState.STRONG,
|
||||||
rules: contentRules.strong
|
rules: contentRules.strong
|
||||||
}
|
}
|
||||||
self.state.externalContentRules = [].concat(contentRules.on, contentRules.other, contentRules.off);
|
self.state.externalContentRules = [].concat(contentRules.strong_but_disabled, contentRules.on, contentRules.on_but_disabled, contentRules.other);
|
||||||
|
}
|
||||||
|
else if (contentRules.strong_but_disabled.length) {
|
||||||
|
self.state.vectorContentRules = {
|
||||||
|
state: PushRuleState.OFF,
|
||||||
|
rules: contentRules.strong_but_disabled
|
||||||
|
}
|
||||||
|
self.state.externalContentRules = [].concat(contentRules.on, contentRules.on_but_disabled, contentRules.other);
|
||||||
}
|
}
|
||||||
else if (contentRules.on.length) {
|
else if (contentRules.on.length) {
|
||||||
self.state.vectorContentRules = {
|
self.state.vectorContentRules = {
|
||||||
state: PushRuleState.ON,
|
state: PushRuleState.ON,
|
||||||
rules: contentRules.on
|
rules: contentRules.on
|
||||||
}
|
}
|
||||||
self.state.externalContentRules = [].concat(contentRules.strong, contentRules.other, contentRules.off);
|
self.state.externalContentRules = [].concat(contentRules.on_but_disabled, contentRules.other);
|
||||||
}
|
}
|
||||||
else if (contentRules.off.length) {
|
else if (contentRules.on_but_disabled.length) {
|
||||||
self.state.vectorContentRules = {
|
self.state.vectorContentRules = {
|
||||||
state: PushRuleState.OFF,
|
state: PushRuleState.OFF,
|
||||||
rules: contentRules.off
|
rules: contentRules.on_but_disabled
|
||||||
}
|
}
|
||||||
self.state.externalContentRules = [].concat(contentRules.strong, contentRules.on, contentRules.other);
|
self.state.externalContentRules = contentRules.other;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.state.externalContentRules = contentRules.other;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the rules displayed by Vector UI
|
// Build the rules displayed by Vector UI
|
||||||
|
Loading…
Reference in New Issue
Block a user