Update MemberList.js

pull/21833/head
Jaiwanth 2021-05-19 17:46:10 +05:30
parent 506a798961
commit d73eb0c70f
1 changed files with 8 additions and 5 deletions

View File

@ -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) { _getMembersState(members) {
// set the state after determining _showPresence to make sure it's // set the state after determining _showPresence to make sure it's
// taken into account while rerendering // taken into account while rerendering
const cli = MatrixClientPeg.get();
return { return {
loading: false, loading: false,
members: members, members: members,
filteredJoinedMembers: this._filterMembers(members, 'join'), filteredJoinedMembers: this._filterMembers(members, 'join'),
filteredInvitedMembers: this._filterMembers(members, 'invite'), 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 // ideally we'd size this to the page height, but
// in practice I find that a little constraining // in practice I find that a little constraining
@ -199,9 +204,7 @@ export default class MemberList extends React.Component {
this._updateList(); this._updateList();
} }
const cli = MatrixClientPeg.get(); if (this.canInvite !== this.state.canInvite) this.setState({ canInvite: this.canInvite });
const canInvite = cli.getRoom(this.props.roomId).canInvite(cli.getUserId());
if (canInvite !== this.state.canInvite) this.setState({canInvite});
}; };
_updateList = rate_limited_func(() => { _updateList = rate_limited_func(() => {