From d73eb0c70f23b4d54a928db6399d2a855a350654 Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Wed, 19 May 2021 17:46:10 +0530 Subject: [PATCH] Update MemberList.js --- src/components/views/rooms/MemberList.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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(() => {