From cae419e304c7fce0e53f746baa39ef37a292fbd2 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 3 Sep 2018 11:13:56 +0200 Subject: [PATCH] avoid rerendering when LL is disabled --- src/components/views/rooms/MemberList.js | 52 +++++++++++++++--------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index b418eef121..d302bee832 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -33,16 +33,16 @@ module.exports = React.createClass({ getInitialState: function() { this.memberDict = this.getMemberDict(); - const members = this.roomMembers(); - return {loading: true}; + const cli = MatrixClientPeg.get(); + if (cli.hasLazyLoadMembersEnabled()) { + return {loading: true}; + } else { + return this._getMembersState(); + } }, - componentDidMount: async function() { - await this._waitForMembersToLoad(); - this.memberDict = this.getMemberDict(); - const members = this.roomMembers(); - + componentWillMount: function() { const cli = MatrixClientPeg.get(); cli.on("RoomState.members", this.onRoomStateMember); cli.on("RoomMember.name", this.onRoomMemberName); @@ -61,20 +61,14 @@ 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: "", - }); + componentDidMount: async function() { + const cli = MatrixClientPeg.get(); + if (cli.hasLazyLoadMembersEnabled()) { + await this._waitForMembersToLoad(); + this.setState(this._getMembersState()); + } }, componentWillUnmount: function() { @@ -101,6 +95,24 @@ module.exports = React.createClass({ } }, + _getMembersState: function() { + const members = this.roomMembers(); + // set the state after determining _showPresence to make sure it's + // taken into account while rerendering + return { + 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: "", + }; + }, + /* onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) { // ignore anything but real-time updates at the end of the room: