From 257dc62a73e2d74a2d42ce700236bccd619a44bd Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 4 Dec 2015 16:15:55 +0000 Subject: [PATCH] Recalculate levels when the member prop is updated. --- src/components/views/rooms/MemberInfo.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index 6b4b441463..81be88fdb8 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -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()