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,7 +119,9 @@ module.exports = React.createClass({
else { // mute else { // mute
level = levelToSend - 1; level = levelToSend - 1;
} }
level = parseInt(level);
if (level !== NaN) {
MatrixClientPeg.get().setPowerLevel(roomId, target, level, powerLevelEvent).done( MatrixClientPeg.get().setPowerLevel(roomId, target, level, 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
@ -132,6 +134,7 @@ module.exports = React.createClass({
}); });
} }
); );
}
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!