From f9c40390e95060c1d457bdc7e03c9379bf70d5b7 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 29 Aug 2018 11:09:55 +0200 Subject: [PATCH] set state after setting _showPresence to avoid all members to appear offline on matrix.org --- src/components/views/rooms/MemberList.js | 27 ++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index ff410ce556..b418eef121 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -43,19 +43,6 @@ module.exports = React.createClass({ this.memberDict = this.getMemberDict(); const members = this.roomMembers(); - this.setState({ - loading: false, - members: members, - filteredJoinedMembers: this._filterMembers(members, 'join'), - filteredInvitedMembers: this._filterMembers(members, 'invite'), - - // ideally we'd size this to the page height, but - // in practice I find that a little constraining - truncateAtJoined: INITIAL_LOAD_NUM_MEMBERS, - truncateAtInvited: INITIAL_LOAD_NUM_INVITED, - searchQuery: "", - }); - const cli = MatrixClientPeg.get(); cli.on("RoomState.members", this.onRoomStateMember); cli.on("RoomMember.name", this.onRoomMemberName); @@ -74,6 +61,20 @@ module.exports = React.createClass({ if (enablePresenceByHsUrl && enablePresenceByHsUrl[hsUrl] !== undefined) { this._showPresence = enablePresenceByHsUrl[hsUrl]; } + // set the state after determining _showPresence to make sure it's + // taken into account while rerendering + this.setState({ + loading: false, + members: members, + filteredJoinedMembers: this._filterMembers(members, 'join'), + filteredInvitedMembers: this._filterMembers(members, 'invite'), + + // ideally we'd size this to the page height, but + // in practice I find that a little constraining + truncateAtJoined: INITIAL_LOAD_NUM_MEMBERS, + truncateAtInvited: INITIAL_LOAD_NUM_INVITED, + searchQuery: "", + }); }, componentWillUnmount: function() {