From fec7d2ee5fcbb5353d06bd5ac6fb3e0d6361afba Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 7 Sep 2018 12:00:19 +0200 Subject: [PATCH] avoid updating the memberlist while the spinner is shown the memberlist gets updated constantly while the LL members are being added to the room state. this slows things down unneed, and is one of the main cause of dropping frames when member arrive. --- src/components/views/rooms/MemberList.js | 29 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index d302bee832..5861348d98 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -33,6 +33,7 @@ module.exports = React.createClass({ getInitialState: function() { this.memberDict = this.getMemberDict(); + this._mounted = false; const cli = MatrixClientPeg.get(); if (cli.hasLazyLoadMembersEnabled()) { @@ -43,6 +44,19 @@ module.exports = React.createClass({ }, componentWillMount: function() { + const cli = MatrixClientPeg.get(); + if (!cli.hasLazyLoadMembersEnabled()) { + this._listenForMembersChanges(); + } + const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"]; + const hsUrl = MatrixClientPeg.get().baseUrl; + this._showPresence = true; + if (enablePresenceByHsUrl && enablePresenceByHsUrl[hsUrl] !== undefined) { + this._showPresence = enablePresenceByHsUrl[hsUrl]; + } + }, + + _listenForMembersChanges: function() { const cli = MatrixClientPeg.get(); cli.on("RoomState.members", this.onRoomStateMember); cli.on("RoomMember.name", this.onRoomMemberName); @@ -53,25 +67,22 @@ module.exports = React.createClass({ // the information contained in presence events). cli.on("User.lastPresenceTs", this.onUserLastPresenceTs); // cli.on("Room.timeline", this.onRoomTimeline); - - const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"]; - const hsUrl = MatrixClientPeg.get().baseUrl; - - this._showPresence = true; - if (enablePresenceByHsUrl && enablePresenceByHsUrl[hsUrl] !== undefined) { - this._showPresence = enablePresenceByHsUrl[hsUrl]; - } }, componentDidMount: async function() { + this._mounted = true; const cli = MatrixClientPeg.get(); if (cli.hasLazyLoadMembersEnabled()) { await this._waitForMembersToLoad(); - this.setState(this._getMembersState()); + if (this._mounted) { + this.setState(this._getMembersState()); + this._listenForMembersChanges(); + } } }, componentWillUnmount: function() { + this._mounted = false; const cli = MatrixClientPeg.get(); if (cli) { cli.removeListener("RoomState.members", this.onRoomStateMember);