avoid rerendering when LL is disabled
This commit is contained in:
parent
f9c40390e9
commit
cae419e304
1 changed files with 32 additions and 20 deletions
|
@ -33,16 +33,16 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
this.memberDict = this.getMemberDict();
|
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() {
|
componentWillMount: function() {
|
||||||
await this._waitForMembersToLoad();
|
|
||||||
this.memberDict = this.getMemberDict();
|
|
||||||
const members = this.roomMembers();
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -61,20 +61,14 @@ module.exports = React.createClass({
|
||||||
if (enablePresenceByHsUrl && enablePresenceByHsUrl[hsUrl] !== undefined) {
|
if (enablePresenceByHsUrl && enablePresenceByHsUrl[hsUrl] !== undefined) {
|
||||||
this._showPresence = enablePresenceByHsUrl[hsUrl];
|
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
|
componentDidMount: async function() {
|
||||||
// in practice I find that a little constraining
|
const cli = MatrixClientPeg.get();
|
||||||
truncateAtJoined: INITIAL_LOAD_NUM_MEMBERS,
|
if (cli.hasLazyLoadMembersEnabled()) {
|
||||||
truncateAtInvited: INITIAL_LOAD_NUM_INVITED,
|
await this._waitForMembersToLoad();
|
||||||
searchQuery: "",
|
this.setState(this._getMembersState());
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
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) {
|
onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) {
|
||||||
// ignore anything but real-time updates at the end of the room:
|
// ignore anything but real-time updates at the end of the room:
|
||||||
|
|
Loading…
Reference in a new issue