Fix comment style

pull/21833/head
Travis Ralston 2020-01-06 12:23:35 -07:00
parent 31d5617c97
commit 6c410e6027
1 changed files with 7 additions and 2 deletions

View File

@ -115,6 +115,8 @@ export default class DMInviteDialog extends React.PureComponent {
const joinedRooms = client.getRooms() const joinedRooms = client.getRooms()
.filter(r => r.getMyMembership() === 'join') .filter(r => r.getMyMembership() === 'join')
.filter(r => r.getJoinedMemberCount() <= maxConsideredMembers); .filter(r => r.getJoinedMemberCount() <= maxConsideredMembers);
// Generates { userId: {member, rooms[]} }
const memberRooms = joinedRooms.reduce((members, room) => { const memberRooms = joinedRooms.reduce((members, room) => {
const joinedMembers = room.getJoinedMembers().filter(u => !excludedUserIds.includes(u.userId)); const joinedMembers = room.getJoinedMembers().filter(u => !excludedUserIds.includes(u.userId));
for (const member of joinedMembers) { for (const member of joinedMembers) {
@ -136,7 +138,9 @@ export default class DMInviteDialog extends React.PureComponent {
} }
} }
return members; return members;
}, {/* userId => {member, rooms[]} */}); }, {});
// Generates { userId: {member, numRooms, score} }
const memberScores = Object.values(memberRooms).reduce((scores, entry) => { const memberScores = Object.values(memberRooms).reduce((scores, entry) => {
const numMembersTotal = entry.rooms.reduce((c, r) => c + r.getJoinedMemberCount(), 0); const numMembersTotal = entry.rooms.reduce((c, r) => c + r.getJoinedMemberCount(), 0);
const maxRange = maxConsideredMembers * entry.rooms.length; const maxRange = maxConsideredMembers * entry.rooms.length;
@ -146,7 +150,8 @@ export default class DMInviteDialog extends React.PureComponent {
score: Math.max(0, Math.pow(1 - (numMembersTotal / maxRange), 5)), score: Math.max(0, Math.pow(1 - (numMembersTotal / maxRange), 5)),
}; };
return scores; return scores;
}, {/* userId => {member, numRooms, score} */}); }, {});
const members = Object.values(memberScores); const members = Object.values(memberScores);
members.sort((a, b) => { members.sort((a, b) => {
if (a.score === b.score) { if (a.score === b.score) {