Skip to content

Commit 15f9f5d

Browse files
committed
Doing the state change via onClick events rather than radio buttons, as they were causeing untraceable react errros for some reason
1 parent 187818a commit 15f9f5d

2 files changed

Lines changed: 41 additions & 14 deletions

File tree

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

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818

1919
var q = require("q");
2020
var React = require('react');
21+
var classNames = require('classnames');
2122
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
2223

2324
module.exports = React.createClass({
@@ -67,31 +68,52 @@ module.exports = React.createClass({
6768
_onToggle: function(ev) {
6869
switch (ev.target.value) {
6970
case "all":
70-
if (this.props.onFinished) {
71-
this._save(false);
72-
this.props.onFinished();
73-
}
71+
this._save(false);
7472
break;
7573
case "mute":
76-
if (this.props.onFinished) {
77-
this._save(true);
78-
this.props.onFinished();
79-
}
74+
this._save(true);
8075
break;
8176
}
77+
78+
if (this.props.onFinished) {
79+
this.props.onFinished();
80+
};
81+
},
82+
83+
_onClickAllNotifs: function() {
84+
this._save(false);
85+
if (this.props.onFinished) {
86+
this.props.onFinished();
87+
};
88+
},
89+
90+
_onClickMute: function() {
91+
this._save(true);
92+
if (this.props.onFinished) {
93+
this.props.onFinished();
94+
};
8295
},
8396

8497
render: function() {
8598
var cli = MatrixClientPeg.get();
99+
100+
var allNotifsClasses = classNames({
101+
'mx_ContextualMenu_field': true,
102+
'mx_ContextualMenu_fieldSet': !this.state.areNotifsMuted,
103+
});
104+
105+
var muteNotifsClasses = classNames({
106+
'mx_ContextualMenu_field': true,
107+
'mx_ContextualMenu_fieldSet': this.state.areNotifsMuted,
108+
});
109+
86110
return (
87111
<div>
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
112+
<div className={ allNotifsClasses } onClick={this._onClickAllNotifs} >
113+
{ !this.state.areNotifsMuted ? "ON" : "OFF" } - All notifications
91114
</div>
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
115+
<div className={ muteNotifsClasses } onClick={this._onClickMute} >
116+
{ this.state.areNotifsMuted ? "ON" : "OFF" } - Mute
95117
</div>
96118
</div>
97119
);

‎src/skins/vector/css/common.css‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ input[type=text]:focus, textarea:focus {
103103
position: fixed;
104104
z-index: 2001;
105105
padding: 6px;
106+
font-size: 14px;
106107
}
107108

108109
.mx_ContextualMenu_chevron_right {
@@ -156,6 +157,10 @@ input[type=text]:focus, textarea:focus {
156157
cursor: pointer;
157158
}
158159

160+
.mx_ContextualMenu_field.mx_ContextualMenu_fieldSet {
161+
font-weight: bold;
162+
}
163+
159164
.mx_ContextualMenu_spinner {
160165
display: block;
161166
margin: 0 auto;

0 commit comments

Comments
 (0)