fix invalid powerlevel setting

This commit is contained in:
Matthew Hodgson 2016-01-22 15:29:57 +00:00
parent 4775f39e1d
commit 0bdd674f7f

View file

@ -119,19 +119,22 @@ module.exports = React.createClass({
else { // mute else { // mute
level = levelToSend - 1; level = levelToSend - 1;
} }
level = parseInt(level);
MatrixClientPeg.get().setPowerLevel(roomId, target, level, powerLevelEvent).done( if (level !== NaN) {
function() { MatrixClientPeg.get().setPowerLevel(roomId, target, level, powerLevelEvent).done(
// NO-OP; rely on the m.room.member event coming down else we could function() {
// get out of sync if we force setState here! // NO-OP; rely on the m.room.member event coming down else we could
console.log("Mute toggle success"); // get out of sync if we force setState here!
}, function(err) { console.log("Mute toggle success");
Modal.createDialog(ErrorDialog, { }, function(err) {
title: "Mute error", Modal.createDialog(ErrorDialog, {
description: err.message title: "Mute error",
}); description: err.message
} });
); }
);
}
this.props.onFinished(); this.props.onFinished();
}, },
@ -161,7 +164,7 @@ module.exports = React.createClass({
if (modLevel > 50 && defaultLevel < 50) modLevel = 50; // try to stick with the vector level defaults if (modLevel > 50 && defaultLevel < 50) modLevel = 50; // try to stick with the vector level defaults
// toggle the level // toggle the level
var newLevel = this.state.isTargetMod ? defaultLevel : modLevel; var newLevel = this.state.isTargetMod ? defaultLevel : modLevel;
MatrixClientPeg.get().setPowerLevel(roomId, target, newLevel, powerLevelEvent).done( MatrixClientPeg.get().setPowerLevel(roomId, target, parseInt(newLevel), powerLevelEvent).done(
function() { function() {
// NO-OP; rely on the m.room.member event coming down else we could // NO-OP; rely on the m.room.member event coming down else we could
// get out of sync if we force setState here! // get out of sync if we force setState here!
@ -192,7 +195,7 @@ module.exports = React.createClass({
this.props.onFinished(); this.props.onFinished();
return; return;
} }
MatrixClientPeg.get().setPowerLevel(roomId, target, powerLevel, powerLevelEvent).done( MatrixClientPeg.get().setPowerLevel(roomId, target, parseInt(powerLevel), powerLevelEvent).done(
function() { function() {
// NO-OP; rely on the m.room.member event coming down else we could // NO-OP; rely on the m.room.member event coming down else we could
// get out of sync if we force setState here! // get out of sync if we force setState here!