When a use clicks the state they want, after the change has been made it pasues breifly before closing, so that the user can see their state change has taken place.

This commit is contained in:
wmwragg 2016-07-28 15:28:05 +01:00
parent 6329e274ab
commit b87058508e
1 changed files with 16 additions and 15 deletions

View File

@ -48,20 +48,27 @@ module.exports = React.createClass({
}, },
_save: function( isMuted ) { _save: function( isMuted ) {
var self = this;
const roomId = this.props.room.roomId; const roomId = this.props.room.roomId;
/*
if (this.state.areNotifsMuted !== originalState.areNotifsMuted) {
promises.push(MatrixClientPeg.get().setRoomMutePushRule(
"global", roomId, this.state.areNotifsMuted
));
}
*/
var cli = MatrixClientPeg.get(); var cli = MatrixClientPeg.get();
this.setState({areNotifsMuted: isMuted});
if (!cli.isGuest()) { if (!cli.isGuest()) {
cli.setRoomMutePushRule( cli.setRoomMutePushRule(
"global", roomId, isMuted "global", roomId, isMuted
); ).then(function() {
console.log("DEBUG: then");
self.setState({areNotifsMuted: isMuted});
// delay slightly so that the user can see their state change
q.delay(500).then(function() {
if (self.props.onFinished) {
self.props.onFinished();
};
});
}).fail(function(error) {
console.log("DEBUG: fail");
console.log(error);
});
} }
}, },
@ -71,9 +78,6 @@ module.exports = React.createClass({
_onClickAllNotifs: function() { _onClickAllNotifs: function() {
this._save(false); this._save(false);
if (this.props.onFinished) {
this.props.onFinished();
};
}, },
_onClickMentions: function() { _onClickMentions: function() {
@ -82,9 +86,6 @@ module.exports = React.createClass({
_onClickMute: function() { _onClickMute: function() {
this._save(true); this._save(true);
if (this.props.onFinished) {
this.props.onFinished();
};
}, },
render: function() { render: function() {