Merge pull request #46 from matrix-org/kegan/ops-level-update
Recalculate levels when the member prop is updated.pull/21833/head
commit
ae615b5c5e
|
@ -43,11 +43,16 @@ module.exports = React.createClass({
|
|||
componentDidMount: function() {
|
||||
// work out the current state
|
||||
if (this.props.member) {
|
||||
var memberState = this._calculateOpsPermissions();
|
||||
var memberState = this._calculateOpsPermissions(this.props.member);
|
||||
this.setState(memberState);
|
||||
}
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function(newProps) {
|
||||
var memberState = this._calculateOpsPermissions(newProps.member);
|
||||
this.setState(memberState);
|
||||
},
|
||||
|
||||
onKick: function() {
|
||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||
var roomId = this.props.member.roomId;
|
||||
|
@ -269,13 +274,13 @@ module.exports = React.createClass({
|
|||
}
|
||||
},
|
||||
|
||||
_calculateOpsPermissions: function() {
|
||||
_calculateOpsPermissions: function(member) {
|
||||
var defaultPerms = {
|
||||
can: {},
|
||||
muted: false,
|
||||
modifyLevel: false
|
||||
};
|
||||
var room = MatrixClientPeg.get().getRoom(this.props.member.roomId);
|
||||
var room = MatrixClientPeg.get().getRoom(member.roomId);
|
||||
if (!room) {
|
||||
return defaultPerms;
|
||||
}
|
||||
|
@ -286,7 +291,7 @@ module.exports = React.createClass({
|
|||
return defaultPerms;
|
||||
}
|
||||
var me = room.getMember(MatrixClientPeg.get().credentials.userId);
|
||||
var them = this.props.member;
|
||||
var them = member;
|
||||
return {
|
||||
can: this._calculateCanPermissions(
|
||||
me, them, powerLevels.getContent()
|
||||
|
|
Loading…
Reference in New Issue