From a17df609f32b44834cbd0e4bccc3a977182bf013 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 12 Aug 2016 15:19:34 +0100 Subject: [PATCH 1/5] Read all 4 different notif states Can't yet set loud / mute --- .../NotificationStateContextMenu.js | 28 ++------ src/notifications/RoomNotifs.js | 70 +++++++++++++++++++ 2 files changed, 76 insertions(+), 22 deletions(-) create mode 100644 src/notifications/RoomNotifs.js diff --git a/src/components/views/context_menus/NotificationStateContextMenu.js b/src/components/views/context_menus/NotificationStateContextMenu.js index 8430f8efc4..21b17fe668 100644 --- a/src/components/views/context_menus/NotificationStateContextMenu.js +++ b/src/components/views/context_menus/NotificationStateContextMenu.js @@ -21,6 +21,7 @@ var React = require('react'); var classNames = require('classnames'); var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); var dis = require('matrix-react-sdk/lib/dispatcher'); +var RoomNotifs = require('../../../notifications/RoomNotifs'); module.exports = React.createClass({ displayName: 'NotificationStateContextMenu', @@ -31,23 +32,6 @@ module.exports = React.createClass({ onFinished: React.PropTypes.func, }, - getInitialState: function() { - var areNotifsMuted = false; - var cli = MatrixClientPeg.get(); - if (!cli.isGuest()) { - var roomPushRule = cli.getRoomPushRule("global", this.props.room.roomId); - if (roomPushRule) { - if (0 <= roomPushRule.actions.indexOf("dont_notify")) { - areNotifsMuted = true; - } - } - } - - return { - areNotifsMuted: areNotifsMuted, - }; - }, - _save: function( areNotifsMuted ) { var self = this; const roomId = this.props.room.roomId; @@ -100,26 +84,26 @@ module.exports = React.createClass({ }, render: function() { - var cli = MatrixClientPeg.get(); + const vectorRoomNotifState = RoomNotifs.getVectorRoomNotifsState(this.props.room.roomId); var alertMeClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldDisabled': true, + 'mx_NotificationStateContextMenu_fieldSet': vectorRoomNotifState == 'all_messages_loud', }); var allNotifsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': !this.state.areNotifsMuted, + 'mx_NotificationStateContextMenu_fieldSet': vectorRoomNotifState == 'all_messages', }); var mentionsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': this.state.areNotifsMuted, + 'mx_NotificationStateContextMenu_fieldSet': vectorRoomNotifState == 'mentions_only', }); var muteNotifsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldDisabled': true, + 'mx_NotificationStateContextMenu_fieldDisabled': vectorRoomNotifState == 'mute', }); return ( diff --git a/src/notifications/RoomNotifs.js b/src/notifications/RoomNotifs.js new file mode 100644 index 0000000000..35b1f1252e --- /dev/null +++ b/src/notifications/RoomNotifs.js @@ -0,0 +1,70 @@ +/* +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. +*/ + +import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; +import PushProcessor from 'matrix-js-sdk/lib/pushprocessor'; + +export function getVectorRoomNotifsState(roomId) { + // look through the override rules for a rule affecting this room: + // if one exists, it will take precedence. + for (const rule of MatrixClientPeg.get().pushRules['global'].override) { + if (isRuleForRoom(roomId, rule)) { + if (isMuteRule(rule)) { + return 'mute'; + } + } + } + + // for everything else, look at the room rule. + const roomRule = MatrixClientPeg.get().getRoomPushRule('global', roomId); + + // XXX: We have to assume the default is to notify for all messages + // (in particular this will be 'wrong' for one to one rooms because + // they will notify loudly for all messages) + if (!roomRule) return 'all_messages'; + + // a mute at the room level will still allow mentions + // to notify + if (isMuteRule(roomRule)) return 'mentions_only'; + + const actionsObject = PushProcessor.actionListToActionsObject(roomRule.actions); + if (actionsObject.tweaks.sound) return 'all_messages_loud'; + + return null; +} + +function isRuleForRoom(roomId, rule) { + if (rule.conditions.length !== 1) { + return false; + } + const cond = rule.conditions[0]; + if ( + cond.kind == 'event_match' && + cond.key == 'room_id' && + cond.pattern == roomId + ) { + return true; + } + return false; +} + +function isMuteRule(rule) { + return ( + rule.actions.length == 1 && + rule.actions[0] == 'dont_notify' + ); +} + From cd0ed879e36e82bb7b391527747e760fbd0d3b4f Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 16 Aug 2016 15:54:28 +0100 Subject: [PATCH 2/5] Make the slider work Still WIP though: need to make vector work with the 'contains display name' rule being an override --- .../NotificationStateContextMenu.js | 52 +++++++----- src/notifications/RoomNotifs.js | 81 +++++++++++++++++-- .../VectorPushRulesDefinitions.js | 2 +- 3 files changed, 105 insertions(+), 30 deletions(-) diff --git a/src/components/views/context_menus/NotificationStateContextMenu.js b/src/components/views/context_menus/NotificationStateContextMenu.js index 21b17fe668..f263f44ac2 100644 --- a/src/components/views/context_menus/NotificationStateContextMenu.js +++ b/src/components/views/context_menus/NotificationStateContextMenu.js @@ -32,78 +32,86 @@ module.exports = React.createClass({ onFinished: React.PropTypes.func, }, - _save: function( areNotifsMuted ) { - var self = this; + getInitialState() { + return { + vectorRoomNotifState: RoomNotifs.getVectorRoomNotifsState(this.props.room.roomId), + } + }, + + _save: function(newState) { + const oldState = this.state.vectorRoomNotifState; const roomId = this.props.room.roomId; var cli = MatrixClientPeg.get(); if (!cli.isGuest()) { // Wrapping this in a q promise, as setRoomMutePushRule can return // a promise or a value - q(cli.setRoomMutePushRule("global", roomId, areNotifsMuted)) - .then(function() { - self.setState({areNotifsMuted: areNotifsMuted}); - + this.setState({ + vectorRoomNotifState: newState, + }); + RoomNotifs.setVectorRoomNotifsState(this.props.room.roomId, newState).done(() => { // delay slightly so that the user can see their state change // before closing the menu - return q.delay(500).then(function() { + return q.delay(500).then(() => { // tell everyone that wants to know of the change in // notification state dis.dispatch({ action: 'notification_change', - roomId: self.props.room.roomId, - areNotifsMuted: areNotifsMuted, + roomId: this.props.room.roomId, + //areNotifsMuted: areNotifsMuted, }); // Close the context menu - if (self.props.onFinished) { - self.props.onFinished(); + if (this.props.onFinished) { + this.props.onFinished(); }; }); - }).fail(function(error) { + }, (error) => { // TODO: some form of error notification to the user // to inform them that their state change failed. + // For now we at least set the state back + this.setState({ + vectorRoomNotifState: oldState, + }); }); } }, _onClickAlertMe: function() { - // Placeholder + this._save('all_messages_loud'); }, _onClickAllNotifs: function() { - this._save(false); + this._save('all_messages'); }, _onClickMentions: function() { - this._save(true); + this._save('mentions_only'); }, _onClickMute: function() { - // Placeholder + this._save('mute'); }, render: function() { - const vectorRoomNotifState = RoomNotifs.getVectorRoomNotifsState(this.props.room.roomId); - var alertMeClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': vectorRoomNotifState == 'all_messages_loud', + 'mx_NotificationStateContextMenu_fieldSet': this.state.vectorRoomNotifState == 'all_messages_loud', }); var allNotifsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': vectorRoomNotifState == 'all_messages', + 'mx_NotificationStateContextMenu_fieldSet': this.state.vectorRoomNotifState == 'all_messages', }); var mentionsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': vectorRoomNotifState == 'mentions_only', + 'mx_NotificationStateContextMenu_fieldSet': this.state.vectorRoomNotifState == 'mentions_only', }); var muteNotifsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldDisabled': vectorRoomNotifState == 'mute', + 'mx_NotificationStateContextMenu_fieldSet': this.state.vectorRoomNotifState == 'mute', }); return ( diff --git a/src/notifications/RoomNotifs.js b/src/notifications/RoomNotifs.js index 35b1f1252e..e07b3ac8c7 100644 --- a/src/notifications/RoomNotifs.js +++ b/src/notifications/RoomNotifs.js @@ -16,16 +16,14 @@ limitations under the License. import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; import PushProcessor from 'matrix-js-sdk/lib/pushprocessor'; +import q from 'q'; export function getVectorRoomNotifsState(roomId) { // look through the override rules for a rule affecting this room: // if one exists, it will take precedence. - for (const rule of MatrixClientPeg.get().pushRules['global'].override) { - if (isRuleForRoom(roomId, rule)) { - if (isMuteRule(rule)) { - return 'mute'; - } - } + const muteRule = findOverrideMuteRule(roomId); + if (muteRule && muteRule.enabled) { + return 'mute'; } // for everything else, look at the room rule. @@ -34,7 +32,7 @@ export function getVectorRoomNotifsState(roomId) { // XXX: We have to assume the default is to notify for all messages // (in particular this will be 'wrong' for one to one rooms because // they will notify loudly for all messages) - if (!roomRule) return 'all_messages'; + if (!roomRule || !roomRule.enabled) return 'all_messages'; // a mute at the room level will still allow mentions // to notify @@ -46,6 +44,75 @@ export function getVectorRoomNotifsState(roomId) { return null; } +export function setVectorRoomNotifsState(roomId, newState) { + const cli = MatrixClientPeg.get(); + const promises = []; + + if (newState == 'mute') { + // delete the room rule + const roomRule = MatrixClientPeg.get().getRoomPushRule('global', roomId); + if (roomRule) { + promises.push(cli.deletePushRule('global', 'room', roomRule.rule_id)); + } + + // add an override rule to squelch everything in this room + promises.push(cli.addPushRule('global', 'override', roomId, { + conditions: [ + { + kind: 'event_match', + key: 'room_id', + pattern: roomId, + } + ], + actions: [ + 'dont_notify', + ] + })); + } else { + const overrideMuteRule = findOverrideMuteRule(roomId); + if (overrideMuteRule) { + promises.push(cli.deletePushRule('global', 'override', overrideMuteRule.rule_id)); + } + + if (newState == 'all_messages') { + promises.push(cli.deletePushRule('global', 'room', roomId)); + } else if (newState == 'mentions_only') { + promises.push(cli.addPushRule('global', 'room', roomId, { + actions: [ + 'dont_notify', + ] + })); + // https://matrix.org/jira/browse/SPEC-400 + promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true)); + } else if ('all_messages_loud') { + promises.push(cli.addPushRule('global', 'room', roomId, { + actions: [ + 'notify', + { + set_tweak: 'sound', + value: 'default', + } + ] + })); + // https://matrix.org/jira/browse/SPEC-400 + promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true)); + } + } + + return q.all(promises); +} + +function findOverrideMuteRule(roomId) { + for (const rule of MatrixClientPeg.get().pushRules['global'].override) { + if (isRuleForRoom(roomId, rule)) { + if (isMuteRule(rule)) { + return rule; + } + } + } + return null; +} + function isRuleForRoom(roomId, rule) { if (rule.conditions.length !== 1) { return false; diff --git a/src/notifications/VectorPushRulesDefinitions.js b/src/notifications/VectorPushRulesDefinitions.js index dfbc06c083..2e90e576ba 100644 --- a/src/notifications/VectorPushRulesDefinitions.js +++ b/src/notifications/VectorPushRulesDefinitions.js @@ -65,7 +65,7 @@ module.exports = { // Messages containing user's display name // (skip contains_user_name which is too geeky) ".m.rule.contains_display_name": new VectorPushRuleDefinition({ - kind: "underride", + kind: "override", description: "Messages containing my name", vectorStateToActions: { // The actions for each vector state, or null to disable the rule. on: StandardActions.ACTION_NOTIFY, From 6b0aeefc66b4defa3269b0e8179f9fde8d3cc94d Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 17 Aug 2016 18:29:38 +0100 Subject: [PATCH 3/5] RoomNotifs.js moved to react-sdk Since it's now used in RoomTile. Remove the vector prefix since it's no longer really a 'vector' thing --- .../NotificationStateContextMenu.js | 29 ++-- src/notifications/RoomNotifs.js | 137 ------------------ 2 files changed, 10 insertions(+), 156 deletions(-) delete mode 100644 src/notifications/RoomNotifs.js diff --git a/src/components/views/context_menus/NotificationStateContextMenu.js b/src/components/views/context_menus/NotificationStateContextMenu.js index f263f44ac2..3e6cb1fafd 100644 --- a/src/components/views/context_menus/NotificationStateContextMenu.js +++ b/src/components/views/context_menus/NotificationStateContextMenu.js @@ -19,9 +19,8 @@ limitations under the License. var q = require("q"); var React = require('react'); var classNames = require('classnames'); +var RoomNotifs = require('matrix-react-sdk/lib/RoomNotifs'); var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); -var dis = require('matrix-react-sdk/lib/dispatcher'); -var RoomNotifs = require('../../../notifications/RoomNotifs'); module.exports = React.createClass({ displayName: 'NotificationStateContextMenu', @@ -34,12 +33,12 @@ module.exports = React.createClass({ getInitialState() { return { - vectorRoomNotifState: RoomNotifs.getVectorRoomNotifsState(this.props.room.roomId), + roomNotifState: RoomNotifs.getRoomNotifsState(this.props.room.roomId), } }, _save: function(newState) { - const oldState = this.state.vectorRoomNotifState; + const oldState = this.state.roomNotifState; const roomId = this.props.room.roomId; var cli = MatrixClientPeg.get(); @@ -47,20 +46,12 @@ module.exports = React.createClass({ // Wrapping this in a q promise, as setRoomMutePushRule can return // a promise or a value this.setState({ - vectorRoomNotifState: newState, + roomNotifState: newState, }); - RoomNotifs.setVectorRoomNotifsState(this.props.room.roomId, newState).done(() => { + RoomNotifs.setRoomNotifsState(this.props.room.roomId, newState).done(() => { // delay slightly so that the user can see their state change // before closing the menu return q.delay(500).then(() => { - // tell everyone that wants to know of the change in - // notification state - dis.dispatch({ - action: 'notification_change', - roomId: this.props.room.roomId, - //areNotifsMuted: areNotifsMuted, - }); - // Close the context menu if (this.props.onFinished) { this.props.onFinished(); @@ -71,7 +62,7 @@ module.exports = React.createClass({ // to inform them that their state change failed. // For now we at least set the state back this.setState({ - vectorRoomNotifState: oldState, + roomNotifState: oldState, }); }); } @@ -96,22 +87,22 @@ module.exports = React.createClass({ render: function() { var alertMeClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': this.state.vectorRoomNotifState == 'all_messages_loud', + 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == 'all_messages_loud', }); var allNotifsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': this.state.vectorRoomNotifState == 'all_messages', + 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == 'all_messages', }); var mentionsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': this.state.vectorRoomNotifState == 'mentions_only', + 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == 'mentions_only', }); var muteNotifsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': this.state.vectorRoomNotifState == 'mute', + 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == 'mute', }); return ( diff --git a/src/notifications/RoomNotifs.js b/src/notifications/RoomNotifs.js deleted file mode 100644 index e07b3ac8c7..0000000000 --- a/src/notifications/RoomNotifs.js +++ /dev/null @@ -1,137 +0,0 @@ -/* -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. -*/ - -import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; -import PushProcessor from 'matrix-js-sdk/lib/pushprocessor'; -import q from 'q'; - -export function getVectorRoomNotifsState(roomId) { - // look through the override rules for a rule affecting this room: - // if one exists, it will take precedence. - const muteRule = findOverrideMuteRule(roomId); - if (muteRule && muteRule.enabled) { - return 'mute'; - } - - // for everything else, look at the room rule. - const roomRule = MatrixClientPeg.get().getRoomPushRule('global', roomId); - - // XXX: We have to assume the default is to notify for all messages - // (in particular this will be 'wrong' for one to one rooms because - // they will notify loudly for all messages) - if (!roomRule || !roomRule.enabled) return 'all_messages'; - - // a mute at the room level will still allow mentions - // to notify - if (isMuteRule(roomRule)) return 'mentions_only'; - - const actionsObject = PushProcessor.actionListToActionsObject(roomRule.actions); - if (actionsObject.tweaks.sound) return 'all_messages_loud'; - - return null; -} - -export function setVectorRoomNotifsState(roomId, newState) { - const cli = MatrixClientPeg.get(); - const promises = []; - - if (newState == 'mute') { - // delete the room rule - const roomRule = MatrixClientPeg.get().getRoomPushRule('global', roomId); - if (roomRule) { - promises.push(cli.deletePushRule('global', 'room', roomRule.rule_id)); - } - - // add an override rule to squelch everything in this room - promises.push(cli.addPushRule('global', 'override', roomId, { - conditions: [ - { - kind: 'event_match', - key: 'room_id', - pattern: roomId, - } - ], - actions: [ - 'dont_notify', - ] - })); - } else { - const overrideMuteRule = findOverrideMuteRule(roomId); - if (overrideMuteRule) { - promises.push(cli.deletePushRule('global', 'override', overrideMuteRule.rule_id)); - } - - if (newState == 'all_messages') { - promises.push(cli.deletePushRule('global', 'room', roomId)); - } else if (newState == 'mentions_only') { - promises.push(cli.addPushRule('global', 'room', roomId, { - actions: [ - 'dont_notify', - ] - })); - // https://matrix.org/jira/browse/SPEC-400 - promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true)); - } else if ('all_messages_loud') { - promises.push(cli.addPushRule('global', 'room', roomId, { - actions: [ - 'notify', - { - set_tweak: 'sound', - value: 'default', - } - ] - })); - // https://matrix.org/jira/browse/SPEC-400 - promises.push(cli.setPushRuleEnabled('global', 'room', roomId, true)); - } - } - - return q.all(promises); -} - -function findOverrideMuteRule(roomId) { - for (const rule of MatrixClientPeg.get().pushRules['global'].override) { - if (isRuleForRoom(roomId, rule)) { - if (isMuteRule(rule)) { - return rule; - } - } - } - return null; -} - -function isRuleForRoom(roomId, rule) { - if (rule.conditions.length !== 1) { - return false; - } - const cond = rule.conditions[0]; - if ( - cond.kind == 'event_match' && - cond.key == 'room_id' && - cond.pattern == roomId - ) { - return true; - } - return false; -} - -function isMuteRule(rule) { - return ( - rule.actions.length == 1 && - rule.actions[0] == 'dont_notify' - ); -} - From e48d68a449e22b137a5f2518ebb06ebd04654ef9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 18 Aug 2016 13:11:57 +0100 Subject: [PATCH 4/5] PR feedback --- .../NotificationStateContextMenu.js | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/src/components/views/context_menus/NotificationStateContextMenu.js b/src/components/views/context_menus/NotificationStateContextMenu.js index 3e6cb1fafd..e78483adc4 100644 --- a/src/components/views/context_menus/NotificationStateContextMenu.js +++ b/src/components/views/context_menus/NotificationStateContextMenu.js @@ -37,35 +37,43 @@ module.exports = React.createClass({ } }, + componentWillMount: function() { + this._unmounted = false; + }, + + componentWillUnmount: function() { + this._unmounted = true; + }, + _save: function(newState) { const oldState = this.state.roomNotifState; const roomId = this.props.room.roomId; var cli = MatrixClientPeg.get(); - if (!cli.isGuest()) { - // Wrapping this in a q promise, as setRoomMutePushRule can return - // a promise or a value + if (cli.isGuest()) return; + + this.setState({ + roomNotifState: newState, + }); + RoomNotifs.setRoomNotifsState(this.props.room.roomId, newState).done(() => { + // delay slightly so that the user can see their state change + // before closing the menu + return q.delay(500).then(() => { + if (this._unmounted) return; + // Close the context menu + if (this.props.onFinished) { + this.props.onFinished(); + }; + }); + }, (error) => { + // TODO: some form of error notification to the user + // to inform them that their state change failed. + // For now we at least set the state back + if (this._unmounted) return; this.setState({ - roomNotifState: newState, + roomNotifState: oldState, }); - RoomNotifs.setRoomNotifsState(this.props.room.roomId, newState).done(() => { - // delay slightly so that the user can see their state change - // before closing the menu - return q.delay(500).then(() => { - // Close the context menu - if (this.props.onFinished) { - this.props.onFinished(); - }; - }); - }, (error) => { - // TODO: some form of error notification to the user - // to inform them that their state change failed. - // For now we at least set the state back - this.setState({ - roomNotifState: oldState, - }); - }); - } + }); }, _onClickAlertMe: function() { From 0bb3eaaf67b301e917b0fe63be25579bcc6ca2f2 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 18 Aug 2016 13:46:47 +0100 Subject: [PATCH 5/5] Use constants --- .../NotificationStateContextMenu.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/views/context_menus/NotificationStateContextMenu.js b/src/components/views/context_menus/NotificationStateContextMenu.js index e78483adc4..243275db27 100644 --- a/src/components/views/context_menus/NotificationStateContextMenu.js +++ b/src/components/views/context_menus/NotificationStateContextMenu.js @@ -77,40 +77,40 @@ module.exports = React.createClass({ }, _onClickAlertMe: function() { - this._save('all_messages_loud'); + this._save(RoomNotifs.ALL_MESSAGES_LOUD); }, _onClickAllNotifs: function() { - this._save('all_messages'); + this._save(RoomNotifs.ALL_MESSAGES); }, _onClickMentions: function() { - this._save('mentions_only'); + this._save(RoomNotifs.MENTIONS_ONLY); }, _onClickMute: function() { - this._save('mute'); + this._save(RoomNotifs.MUTE); }, render: function() { var alertMeClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == 'all_messages_loud', + 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == RoomNotifs.ALL_MESSAGES_LOUD, }); var allNotifsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == 'all_messages', + 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == RoomNotifs.ALL_MESSAGES, }); var mentionsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == 'mentions_only', + 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == RoomNotifs.MENTIONS_ONLY, }); var muteNotifsClasses = classNames({ 'mx_NotificationStateContextMenu_field': true, - 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == 'mute', + 'mx_NotificationStateContextMenu_fieldSet': this.state.roomNotifState == RoomNotifs.MUTE, }); return (