avoid rerendering when LL is disabled

This commit is contained in:
Bruno Windels 2018-09-03 11:13:56 +02:00
parent f9c40390e9
commit cae419e304

View file

@ -33,16 +33,16 @@ module.exports = React.createClass({
getInitialState: function() {
this.memberDict = this.getMemberDict();
const members = this.roomMembers();
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: