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.
pull/21833/head
Bruno Windels 2018-09-07 12:00:19 +02:00
parent c8ab8bf5f8
commit fec7d2ee5f
1 changed files with 20 additions and 9 deletions

View File

@ -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);