From f868f7813b031969ec42ab832fd86cf697d682de Mon Sep 17 00:00:00 2001 From: manuroe Date: Thu, 14 Jan 2016 19:06:48 +0100 Subject: [PATCH] Room settings: Added notifications mute checkbox --- src/components/structures/RoomView.js | 8 ++++++++ src/components/views/rooms/RoomSettings.js | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index c622a7d769..25d95fdc41 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -804,6 +804,13 @@ module.exports = React.createClass({ ); } + // setRoomMutePushRule will do nothing if there is no change + deferreds.push( + MatrixClientPeg.get().setRoomMutePushRule( + "global", this.state.room.roomId, newVals.are_notifications_muted + ) + ); + if (newVals.power_levels) { deferreds.push( MatrixClientPeg.get().sendStateEvent( @@ -908,6 +915,7 @@ module.exports = React.createClass({ topic: this.refs.room_settings.getTopic(), join_rule: this.refs.room_settings.getJoinRules(), history_visibility: this.refs.room_settings.getHistoryVisibility(), + are_notifications_muted: this.refs.room_settings.areNotificationsMuted(), power_levels: this.refs.room_settings.getPowerLevels(), guest_join: this.refs.room_settings.canGuestsJoin(), guest_read: this.refs.room_settings.canGuestsRead() diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 9e07385d65..e402ac8488 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -51,6 +51,10 @@ module.exports = React.createClass({ return this.refs.share_history.checked ? "shared" : "invited"; }, + areNotificationsMuted: function() { + return this.refs.are_notifications_muted.checked; + }, + getPowerLevels: function() { if (!this.state.power_levels_changed) return undefined; @@ -96,6 +100,14 @@ module.exports = React.createClass({ guest_access = guest_access.getContent().guest_access; } + var are_notifications_muted; + var roomPushRule = MatrixClientPeg.get().getRoomPushRule("global", this.props.room.roomId); + if (roomPushRule) { + if (0 <= roomPushRule.actions.indexOf("dont_notify")) { + are_notifications_muted = true; + } + } + var events_levels = power_levels.events || {}; if (power_levels) { @@ -176,6 +188,11 @@ module.exports = React.createClass({

+

Notifications

+
+ +
+

Power levels