@@ -48,26 +48,27 @@ module.exports = React.createClass({
4848 } ;
4949 } ,
5050
51- _save : function ( isMuted ) {
51+ _save : function ( areNotifsMuted ) {
5252 var self = this ;
5353 const roomId = this . props . room . roomId ;
5454 var cli = MatrixClientPeg . get ( ) ;
5555
5656 if ( ! cli . isGuest ( ) ) {
57- cli . setRoomMutePushRule (
58- "global" , roomId , isMuted
59- ) . then ( function ( ) {
60- self . setState ( { areNotifsMuted : isMuted } ) ;
57+ // Wrapping this in a q promise, as setRoomMutePushRule can return
58+ // a promise or a value
59+ q ( cli . setRoomMutePushRule ( "global" , roomId , areNotifsMuted ) )
60+ . then ( function ( s ) {
61+ self . setState ( { areNotifsMuted : areNotifsMuted } ) ;
6162
6263 // delay slightly so that the user can see their state change
6364 // before closing the menu
64- q . delay ( 500 ) . then ( function ( ) {
65+ return q . delay ( 500 ) . then ( function ( ) {
6566 // tell everyone that wants to know of the change in
6667 // notification state
6768 dis . dispatch ( {
6869 action : 'notification_change' ,
6970 roomId : self . props . room . roomId ,
70- isMuted : isMuted ,
71+ areNotifsMuted : areNotifsMuted ,
7172 } ) ;
7273
7374 // Close the context menu
@@ -91,11 +92,11 @@ module.exports = React.createClass({
9192 } ,
9293
9394 _onClickMentions : function ( ) {
94- // Placeholder
95+ this . _save ( true ) ;
9596 } ,
9697
9798 _onClickMute : function ( ) {
98- this . _save ( true ) ;
99+ // Placeholder
99100 } ,
100101
101102 render : function ( ) {
@@ -113,12 +114,12 @@ module.exports = React.createClass({
113114
114115 var mentionsClasses = classNames ( {
115116 'mx_NotificationStateContextMenu_field' : true ,
116- 'mx_NotificationStateContextMenu_fieldDisabled ' : true ,
117+ 'mx_NotificationStateContextMenu_fieldSet ' : this . state . areNotifsMuted ,
117118 } ) ;
118119
119120 var muteNotifsClasses = classNames ( {
120121 'mx_NotificationStateContextMenu_field' : true ,
121- 'mx_NotificationStateContextMenu_fieldSet ' : this . state . areNotifsMuted ,
122+ 'mx_NotificationStateContextMenu_fieldDisabled ' : true ,
122123 } ) ;
123124
124125 return (
@@ -127,6 +128,7 @@ module.exports = React.createClass({
127128 < img src = "img/notif-slider.svg" width = "20" height = "107" />
128129 </ div >
129130 < div className = { alertMeClasses } onClick = { this . _onClickAlertMe } >
131+ < img className = "mx_NotificationStateContextMenu_activeIcon" src = "img/notif-active.svg" width = "12" height = "12" />
130132 < img className = "mx_NotificationStateContextMenu_icon" src = "img/icon-context-mute-off-copy.svg" width = "16" height = "12" />
131133 All messages (loud)
132134 </ div >
@@ -136,6 +138,7 @@ module.exports = React.createClass({
136138 All messages
137139 </ div >
138140 < div className = { mentionsClasses } onClick = { this . _onClickMentions } >
141+ < img className = "mx_NotificationStateContextMenu_activeIcon" src = "img/notif-active.svg" width = "12" height = "12" />
139142 < img className = "mx_NotificationStateContextMenu_icon" src = "img/icon-context-mute-mentions.svg" width = "16" height = "12" />
140143 Mentions only
141144 </ div >
0 commit comments