mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Fixes to refactored notifications
A few things I managed to break in the recent refactor
This commit is contained in:
parent
ff5dff45f5
commit
0996a0b140
@ -16,6 +16,8 @@ limitations under the License.
|
||||
|
||||
'use strict';
|
||||
|
||||
var StandardActions = require('./StandardActions');
|
||||
|
||||
/**
|
||||
* Enum for state of a push rule as defined by the Vector UI.
|
||||
* @readonly
|
||||
@ -39,10 +41,10 @@ module.exports = {
|
||||
*/
|
||||
actionsFor: function(pushRuleVectorState) {
|
||||
if (pushRuleVectorState === this.ON) {
|
||||
return ACTION_NOTIFY;
|
||||
return StandardActions.ACTION_NOTIFY;
|
||||
}
|
||||
else if (pushRuleVectorState === this.LOUD) {
|
||||
return ACTION_HIGHLIGHT_DEFAULT_SOUND;
|
||||
return StandardActions.ACTION_HIGHLIGHT_DEFAULT_SOUND;
|
||||
}
|
||||
},
|
||||
|
||||
|
30
src/notifications/StandardActions.js
Normal file
30
src/notifications/StandardActions.js
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var NotificationUtils = require('./NotificationUtils');
|
||||
|
||||
var encodeActions = NotificationUtils.encodeActions;
|
||||
|
||||
module.exports = {
|
||||
ACTION_NOTIFY: encodeActions({notify: true}),
|
||||
ACTION_NOTIFY_DEFAULT_SOUND: encodeActions({notify: true, sound: "default"}),
|
||||
ACTION_NOTIFY_RING_SOUND: encodeActions({notify: true, sound: "ring"}),
|
||||
ACTION_HIGHLIGHT_DEFAULT_SOUND: encodeActions({notify: true, sound: "default", highlight: true}),
|
||||
ACTION_DONT_NOTIFY: encodeActions({notify: false}),
|
||||
ACTION_DISABLED: null,
|
||||
};
|
@ -16,17 +16,7 @@ limitations under the License.
|
||||
|
||||
'use strict';
|
||||
|
||||
var NotificationUtils = require('./NotificationUtils');
|
||||
|
||||
var encodeActions = NotificationUtils.encodeActions;
|
||||
var decodeActions = NotificationUtils.decodeActions;
|
||||
|
||||
const ACTION_NOTIFY = encodeActions({notify: true});
|
||||
const ACTION_NOTIFY_DEFAULT_SOUND = encodeActions({notify: true, sound: "default"});
|
||||
const ACTION_NOTIFY_RING_SOUND = encodeActions({notify: true, sound: "ring"});
|
||||
const ACTION_HIGHLIGHT_DEFAULT_SOUND = encodeActions({notify: true, sound: "default", highlight: true});
|
||||
const ACTION_DONT_NOTIFY = encodeActions({notify: false});
|
||||
const ACTION_DISABLED = null;
|
||||
var StandardActions = require('./StandardActions');
|
||||
|
||||
/**
|
||||
* The descriptions of rules managed by the Vector UI.
|
||||
@ -38,9 +28,9 @@ module.exports = {
|
||||
kind: "underride",
|
||||
description: "Messages containing my name",
|
||||
vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
|
||||
on: ACTION_NOTIFY,
|
||||
loud: ACTION_HIGHLIGHT_DEFAULT_SOUND,
|
||||
off: ACTION_DISABLED
|
||||
on: StandardActions.ACTION_NOTIFY,
|
||||
loud: StandardActions.ACTION_HIGHLIGHT_DEFAULT_SOUND,
|
||||
off: StandardActions.ACTION_DISABLED
|
||||
}
|
||||
},
|
||||
|
||||
@ -49,9 +39,9 @@ module.exports = {
|
||||
kind: "underride",
|
||||
description: "Messages in one-to-one chats",
|
||||
vectorStateToActions: {
|
||||
on: ACTION_NOTIFY,
|
||||
loud: ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
off: ACTION_DONT_NOTIFY
|
||||
on: StandardActions.ACTION_NOTIFY,
|
||||
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
off: StandardActions.ACTION_DONT_NOTIFY
|
||||
}
|
||||
},
|
||||
|
||||
@ -62,9 +52,9 @@ module.exports = {
|
||||
kind: "underride",
|
||||
description: "Messages in group chats",
|
||||
vectorStateToActions: {
|
||||
on: ACTION_NOTIFY,
|
||||
loud: ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
off: ACTION_DONT_NOTIFY
|
||||
on: StandardActions.ACTION_NOTIFY,
|
||||
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
off: StandardActions.ACTION_DONT_NOTIFY
|
||||
}
|
||||
},
|
||||
|
||||
@ -73,9 +63,9 @@ module.exports = {
|
||||
kind: "underride",
|
||||
description: "When I'm invited to a room",
|
||||
vectorStateToActions: {
|
||||
on: ACTION_NOTIFY,
|
||||
loud: ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
off: ACTION_DISABLED
|
||||
on: StandardActions.ACTION_NOTIFY,
|
||||
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
off: StandardActions.ACTION_DISABLED
|
||||
}
|
||||
},
|
||||
|
||||
@ -84,9 +74,9 @@ module.exports = {
|
||||
kind: "underride",
|
||||
description: "Call invitation",
|
||||
vectorStateToActions: {
|
||||
on: ACTION_NOTIFY,
|
||||
loud: ACTION_NOTIFY_RING_SOUND,
|
||||
off: ACTION_DISABLED
|
||||
on: StandardActions.ACTION_NOTIFY,
|
||||
loud: StandardActions.ACTION_NOTIFY_RING_SOUND,
|
||||
off: StandardActions.ACTION_DISABLED
|
||||
}
|
||||
},
|
||||
|
||||
@ -96,9 +86,9 @@ module.exports = {
|
||||
description: "Messages sent by bot",
|
||||
vectorStateToActions: {
|
||||
// .m.rule.suppress_notices is a "negative" rule, we have to invert its enabled value for vector UI
|
||||
on: ACTION_DISABLED,
|
||||
loud: ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
off: ACTION_DONT_NOTIFY,
|
||||
on: StandardActions.ACTION_DISABLED,
|
||||
loud: StandardActions.ACTION_NOTIFY_DEFAULT_SOUND,
|
||||
off: StandardActions.ACTION_DONT_NOTIFY,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user