Skip to content

Commit 187818a

Browse files
committed
Radio buttons now added, and only none guests can modify notfication state
1 parent 30b1e70 commit 187818a

1 file changed

Lines changed: 28 additions & 36 deletions

File tree

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

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,6 @@ module.exports = React.createClass({
4646
};
4747
},
4848

49-
onAllClick: function() {
50-
if (this.props.onFinished) {
51-
this.setState({areNotifsMuted: false});
52-
this._save(false);
53-
this.props.onFinished();
54-
}
55-
},
56-
57-
onMuteClick: function() {
58-
if (this.props.onFinished) {
59-
this.setState({areNotifsMuted: true});
60-
this._save(true);
61-
this.props.onFinished();
62-
}
63-
},
64-
6549
_save: function( isMuted ) {
6650
const roomId = this.props.room.roomId;
6751
/*
@@ -71,35 +55,43 @@ module.exports = React.createClass({
7155
));
7256
}
7357
*/
74-
MatrixClientPeg.get().setRoomMutePushRule(
75-
"global", roomId, isMuted
76-
);
58+
var cli = MatrixClientPeg.get();
59+
this.setState({areNotifsMuted: isMuted});
60+
if (!cli.isGuest()) {
61+
cli.setRoomMutePushRule(
62+
"global", roomId, isMuted
63+
);
64+
}
7765
},
7866

79-
_onToggle: function(keyName, checkedValue, uncheckedValue, ev) {
80-
console.log("Checkbox toggle: %s %s", keyName, ev.target.checked);
81-
var state = {};
82-
state[keyName] = ev.target.checked ? checkedValue : uncheckedValue;
83-
this.setState(state);
67+
_onToggle: function(ev) {
68+
switch (ev.target.value) {
69+
case "all":
70+
if (this.props.onFinished) {
71+
this._save(false);
72+
this.props.onFinished();
73+
}
74+
break;
75+
case "mute":
76+
if (this.props.onFinished) {
77+
this._save(true);
78+
this.props.onFinished();
79+
}
80+
break;
81+
}
8482
},
8583

8684
render: function() {
8785
var cli = MatrixClientPeg.get();
8886
return (
8987
<div>
90-
{/*
91-
<div className="mx_ContextualMenu_field">
92-
<input type="checkbox" disabled={ cli.isGuest() }
93-
onChange={this._onToggle.bind(this, "areNotifsMuted", true, false)}
94-
defaultChecked={this.state.areNotifsMuted}/>
95-
Mute notifications for this room
96-
</div>
97-
*/}
98-
<div className="mx_ContextualMenu_field" onClick={ this.onAllClick }>
99-
All notifications - { this.state.areNotifsMuted ? "OFF" : "ON" }
88+
<div className="mx_ContextualMenu_field" >
89+
<input disabled={cli.isGuest()} type="radio" name="notification_state" value="all" onChange={this._onToggle} checked={!this.state.areNotifsMuted}/>
90+
All notifications
10091
</div>
101-
<div className="mx_ContextualMenu_field" onClick={ this.onMuteClick }>
102-
Mute - { this.state.areNotifsMuted ? "ON" : "OFF" }
92+
<div className="mx_ContextualMenu_field" >
93+
<input disabled={cli.isGuest()} type="radio" name="notification_state" value="mute" onChange={this._onToggle} checked={this.state.areNotifsMuted}/>
94+
Mute
10395
</div>
10496
</div>
10597
);

0 commit comments

Comments
 (0)