Skip to content

Commit 3b2d0a6

Browse files
committed
Fix up reading the push rules
1 parent 731d94e commit 3b2d0a6

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

‎src/components/views/settings/Notifications.js‎

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,23 @@ var PushRuleVectorState = {
3838
};
3939

4040

41-
var ACTION_NOTIFY = [ "notify" ];
41+
var ACTION_NOTIFY = [
42+
"notify",
43+
{
44+
"set_tweak": "highlight",
45+
"value": false
46+
}
47+
];
4248

4349
var ACTION_NOTIFY_DEFAULT_SOUND = [
4450
"notify",
4551
{
4652
"set_tweak": "sound",
4753
"value": "default"
54+
},
55+
{
56+
"set_tweak": "highlight",
57+
"value": false
4858
}
4959
];
5060

@@ -53,6 +63,10 @@ var ACTION_NOTIFY_RING_SOUND = [
5363
{
5464
"set_tweak": "sound",
5565
"value": "ring"
66+
},
67+
{
68+
"set_tweak": "highlight",
69+
"value": false
5670
}
5771
];
5872

@@ -87,7 +101,7 @@ var VectorPushRulesDefinitions = {
87101
description: "Messages containing my name",
88102
vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
89103
on: ACTION_NOTIFY,
90-
loud: ACTION_HIGHLIGHT_DEFAULT,
104+
loud: ACTION_HIGHLIGHT_DEFAULT_SOUND,
91105
off: ACTION_DISABLED
92106
}
93107
},
@@ -106,7 +120,7 @@ var VectorPushRulesDefinitions = {
106120
// Messages just sent to a group chat room
107121
// 1:1 room messages are catched by the .m.rule.room_one_to_one rule if any defined
108122
// By opposition, all other room messages are from group chat rooms.
109-
".m.rule.room_message": {
123+
".m.rule.message": {
110124
kind: "underride",
111125
description: "Messages in group chats",
112126
vectorStateToActions: {
@@ -266,10 +280,10 @@ module.exports = React.createClass({
266280

267281
_actionsFor: function(pushRuleVectorState) {
268282
if (pushRuleVectorState === PushRuleVectorState.ON) {
269-
return ACTIONS_NOTIFY;
283+
return ACTION_NOTIFY;
270284
}
271285
else if (pushRuleVectorState === PushRuleVectorState.LOUD) {
272-
return ACTIONS_HIGHLIGHT_DEFAULT_SOUND;
286+
return ACTION_HIGHLIGHT_DEFAULT_SOUND;
273287
}
274288
},
275289

@@ -311,9 +325,9 @@ module.exports = React.createClass({
311325
var ruleDefinition = VectorPushRulesDefinitions[rule.vectorRuleId];
312326

313327
if (rule.rule) {
314-
var actions = ruleDefinition.vectorStateToActions(newPushRuleVectorState);
328+
var actions = ruleDefinition.vectorStateToActions[newPushRuleVectorState];
315329

316-
if (actions === ACTIONS_DISABLED) {
330+
if (actions === ACTION_DISABLED) {
317331
// The new state corresponds to disabling the rule.
318332
deferreds.push(cli.setPushRuleEnabled('global', rule.rule.kind, rule.rule.rule_id, false));
319333
}
@@ -648,11 +662,11 @@ module.exports = React.createClass({
648662
'.m.rule.contains_display_name',
649663
'_keywords',
650664
'.m.rule.room_one_to_one',
651-
'.m.rule.room_message',
665+
'.m.rule.message',
652666
'.m.rule.invite_for_me',
653667
//'im.vector.rule.member_event',
654668
'.m.rule.call',
655-
'.m.rule.notices'
669+
'.m.rule.suppress_notices'
656670
];
657671
for (var i in vectorRuleIds) {
658672
var vectorRuleId = vectorRuleIds[i];
@@ -678,7 +692,7 @@ module.exports = React.createClass({
678692
var state = PushRuleVectorState[stateKey];
679693
var vectorStateToActions = ruleDefinition.vectorStateToActions[state];
680694

681-
if (vectorStateToActions === ACTIONS_DISABLED) {
695+
if (vectorStateToActions === ACTION_DISABLED) {
682696
// No defined actions means that this vector state expects a disabled default hs rule
683697
if (rule.enabled === false) {
684698
vectorState = state;

0 commit comments

Comments
 (0)