Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix CPU spin on joining large room #2128

Merged
merged 2 commits into from
Aug 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/structures/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ module.exports = React.createClass({
}

this._updateRoomMembers();
this._checkIfAlone(this.state.room);
},

onRoomMemberMembership: function(ev, member, oldMembership) {
Expand All @@ -717,6 +716,7 @@ module.exports = React.createClass({
// refresh the conf call notification state
this._updateConfCallNotification();
this._updateDMState();
this._checkIfAlone(this.state.room);
}, 500),

_checkIfAlone: function(room) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this should now be implemented with roomstate getJoinedMemberCount + getInvitedMemberCount, which should be more performant and also more correct in case of lazy loading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, good point

Expand All @@ -729,8 +729,8 @@ module.exports = React.createClass({
return;
}

const joinedMembers = room.currentState.getMembers().filter((m) => m.membership === "join" || m.membership === "invite");
this.setState({isAlone: joinedMembers.length === 1});
const joinedOrInvitedMemberCount = room.getJoinedMemberCount() + room.getInvitedMemberCount();
this.setState({isAlone: joinedOrInvitedMemberCount === 1});
},

_updateConfCallNotification: function() {
Expand Down