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.
This commit is contained in:
parent
c8ab8bf5f8
commit
fec7d2ee5f
1 changed files with 20 additions and 9 deletions
|
@ -33,6 +33,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
this.memberDict = this.getMemberDict();
|
this.memberDict = this.getMemberDict();
|
||||||
|
this._mounted = false;
|
||||||
|
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
if (cli.hasLazyLoadMembersEnabled()) {
|
if (cli.hasLazyLoadMembersEnabled()) {
|
||||||
|
@ -43,6 +44,19 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
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();
|
const cli = MatrixClientPeg.get();
|
||||||
cli.on("RoomState.members", this.onRoomStateMember);
|
cli.on("RoomState.members", this.onRoomStateMember);
|
||||||
cli.on("RoomMember.name", this.onRoomMemberName);
|
cli.on("RoomMember.name", this.onRoomMemberName);
|
||||||
|
@ -53,25 +67,22 @@ module.exports = React.createClass({
|
||||||
// the information contained in presence events).
|
// the information contained in presence events).
|
||||||
cli.on("User.lastPresenceTs", this.onUserLastPresenceTs);
|
cli.on("User.lastPresenceTs", this.onUserLastPresenceTs);
|
||||||
// cli.on("Room.timeline", this.onRoomTimeline);
|
// 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() {
|
componentDidMount: async function() {
|
||||||
|
this._mounted = true;
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
if (cli.hasLazyLoadMembersEnabled()) {
|
if (cli.hasLazyLoadMembersEnabled()) {
|
||||||
await this._waitForMembersToLoad();
|
await this._waitForMembersToLoad();
|
||||||
this.setState(this._getMembersState());
|
if (this._mounted) {
|
||||||
|
this.setState(this._getMembersState());
|
||||||
|
this._listenForMembersChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
|
this._mounted = false;
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
if (cli) {
|
if (cli) {
|
||||||
cli.removeListener("RoomState.members", this.onRoomStateMember);
|
cli.removeListener("RoomState.members", this.onRoomStateMember);
|
||||||
|
|
Loading…
Reference in a new issue