From e78206301fbc1951791b1dbd41693e1feae60244 Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Wed, 19 May 2021 14:31:04 +0530 Subject: [PATCH] Modify to avoid forceUpdate --- src/components/views/rooms/MemberList.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index bb60c958f7..f991827091 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -136,11 +136,13 @@ export default class MemberList extends React.Component { _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()), // ideally we'd size this to the page height, but // in practice I find that a little constraining @@ -196,9 +198,10 @@ export default class MemberList extends React.Component { event.getType() === "m.room.third_party_invite") { this._updateList(); } - if (event.getContent().invite !== event.getPrevContent().invite) { - this.forceUpdate(); - } + + const cli = MatrixClientPeg.get(); + const canInvite = cli.getRoom(this.props.roomId).canInvite(cli.getUserId()); + if (canInvite !== this.state.canInvite) this.setState({canInvite}); }; _updateList = rate_limited_func(() => { @@ -458,8 +461,6 @@ export default class MemberList extends React.Component { let inviteButton; if (room && room.getMyMembership() === 'join') { - const canInvite = room.canInvite(cli.getUserId()); - let inviteButtonText = _t("Invite to this room"); const chat = CommunityPrototypeStore.instance.getSelectedCommunityGeneralChat(); if (chat && chat.roomId === this.props.roomId) { @@ -470,7 +471,7 @@ export default class MemberList extends React.Component { const AccessibleButton = sdk.getComponent("elements.AccessibleButton"); inviteButton = - + { inviteButtonText } ; }