diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index f991827091..55fe650b7b 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -133,16 +133,21 @@ export default class MemberList extends React.Component { } } + get canInvite() { + const cli = MatrixClientPeg.get(); + const room = cli.getRoom(this.props.roomId); + return room && room.canInvite(cli.getUserId()); + } + _getMembersState(members) { // set the state after determining _showPresence to make sure it's // taken into account while rerendering - const cli = MatrixClientPeg.get(); return { loading: false, members: members, filteredJoinedMembers: this._filterMembers(members, 'join'), filteredInvitedMembers: this._filterMembers(members, 'invite'), - canInvite: cli.getRoom(this.props.roomId).canInvite(cli.getUserId()), + canInvite: this.canInvite, // ideally we'd size this to the page height, but // in practice I find that a little constraining @@ -199,9 +204,7 @@ export default class MemberList extends React.Component { this._updateList(); } - const cli = MatrixClientPeg.get(); - const canInvite = cli.getRoom(this.props.roomId).canInvite(cli.getUserId()); - if (canInvite !== this.state.canInvite) this.setState({canInvite}); + if (this.canInvite !== this.state.canInvite) this.setState({ canInvite: this.canInvite }); }; _updateList = rate_limited_func(() => {