Skip to content

Commit 9962506

Browse files
authored
Merge pull request element-hq#1926 from vector-im/wmwragg/mute-mention-state-fix
Wmwragg/mute mention state fix
2 parents a190862 + b99e759 commit 9962506

3 files changed

Lines changed: 24 additions & 60 deletions

File tree

‎src/components/views/context_menus/NotificationStateContextMenu.js‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

‎src/skins/vector/css/matrix-react-sdk/views/rooms/RoomTile.css‎

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ limitations under the License.
2222
height: 34px;
2323
}
2424

25-
.mx_RoomTile .mx_RoomTile_mute {
26-
opacity: 0.4;
27-
}
28-
2925
.mx_RoomTile_nameContainer {
3026
display: inline-block;
3127
width: 180px;
@@ -85,30 +81,13 @@ limitations under the License.
8581
z-index: 200;
8682
}
8783

88-
/* Position mute icon when room muted and collapsed - invisible at the moment */
89-
.collapsed .mx_RoomTile .mx_RoomTile_badge.mx_RoomTile_badgeMute {
90-
background-color: rgba(0,0,0,0);
91-
opacity: 0;
92-
top: -2px;
93-
}
94-
95-
/* Position menu icon when room muted and collapsed */
96-
.collapsed .mx_RoomTile .mx_RoomTile_badge.mx_RoomTile_badgeButton.mx_RoomTile_badgeMute,
97-
.collapsed .mx_RoomTile .mx_RoomTile_badge.mx_RoomTile_badgeButton.mx_RoomTile_badgeMute {
98-
display: inline-block;
99-
background-color: rgb(214, 214, 214);
100-
letter-spacing: 0.1em;
101-
opacity: 1;
102-
top: -2px;
103-
}
104-
10584
/* Hide the bottom of speech bubble */
106-
.collapsed .mx_RoomTile_highlight .mx_RoomTile_badge:not(.mx_RoomTile_badgeMute):after {
85+
.collapsed .mx_RoomTile_highlight .mx_RoomTile_badge:after {
10786
display: none;
10887
}
10988

110-
/* This is the bottom of the speech bubble - not drawn when room muted */
111-
.mx_RoomTile_highlight .mx_RoomTile_badge:not(.mx_RoomTile_badgeMute):after {
89+
/* This is the bottom of the speech bubble */
90+
.mx_RoomTile_highlight .mx_RoomTile_badge:after {
11291
content: "";
11392
position: absolute;
11493
display: block;
@@ -142,22 +121,9 @@ limitations under the License.
142121
opacity: 1;
143122
}
144123

145-
/* Position menu icon when room muted */
146-
.mx_RoomTile .mx_RoomTile_badge.mx_RoomTile_badgeButton.mx_RoomTile_badgeMute,
147-
.mx_RoomTile .mx_RoomTile_badge.mx_RoomTile_badgeButton.mx_RoomTile_badgeMute {
124+
.mx_RoomTile.mx_RoomTile_noBadges .mx_RoomTile_badge.mx_RoomTile_badgeButton,
125+
.mx_RoomTile.mx_RoomTile_menu.mx_RoomTile_noBadges .mx_RoomTile_badge {
148126
background-color: rgb(214, 214, 214);
149-
letter-spacing: 0.1em;
150-
opacity: 1;
151-
top: 9px;
152-
right: 8px; /* gutter */
153-
}
154-
155-
/* Position mute icon when room muted */
156-
.mx_RoomTile .mx_RoomTile_badge.mx_RoomTile_badgeMute {
157-
background-color: rgba(0,0,0,0);
158-
opacity: 1;
159-
top: 11px;
160-
right: 6px;
161127
}
162128

163129
.mx_RoomTile_unreadNotify .mx_RoomTile_badge {
@@ -168,11 +134,6 @@ limitations under the License.
168134
background-color: #ff0064;
169135
}
170136

171-
.mx_RoomTile_read .mx_RoomTile_badge {
172-
background-color: rgb(214, 214, 214);
173-
opacity: 0;
174-
}
175-
176137
.mx_RoomTile_unread, .mx_RoomTile_highlight {
177138
font-weight: 800;
178139
}
@@ -182,7 +143,7 @@ limitations under the License.
182143
}
183144

184145
.mx_RoomTile .mx_RoomTile_name.mx_RoomTile_badgeShown {
185-
width: 144px;
146+
width: 140px;
186147
}
187148

188149
.mx_RoomTile_arrow {

‎src/skins/vector/css/vector-web/views/context_menus/NotificationStateContextMenu.css‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ limitations under the License.
2424
padding-top: 4px;
2525
padding-right: 6px;
2626
padding-bottom: 10px;
27-
padding-left: 20px;
27+
padding-left: 8px; /* 20px */
2828
cursor: pointer;
2929
white-space: nowrap;
3030
display: flex;
@@ -33,7 +33,6 @@ limitations under the License.
3333

3434
.mx_NotificationStateContextMenu_field.mx_NotificationStateContextMenu_fieldSet {
3535
font-weight: bold;
36-
padding-left: 8px;
3736
}
3837

3938
.mx_NotificationStateContextMenu_field.mx_NotificationStateContextMenu_fieldDisabled {
@@ -46,11 +45,12 @@ limitations under the License.
4645
}
4746

4847
.mx_NotificationStateContextMenu_activeIcon {
49-
display: none;
48+
display: inline-block;
49+
opacity: 0;
5050
position: relative;
5151
left: -5px;
5252
}
5353

5454
.mx_NotificationStateContextMenu_fieldSet .mx_NotificationStateContextMenu_activeIcon {
55-
display: inline-block;
55+
opacity: 1;
5656
}

0 commit comments

Comments
 (0)