Merge pull request #1591 from matrix-org/luke/groups-order-admins-first

Order users in the group member list with admins first
This commit is contained in:
David Baker 2017-11-08 14:04:28 +00:00 committed by GitHub
commit b575df7da7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -108,15 +108,21 @@ export default withMatrixClient(React.createClass({
if (!uniqueMembers[m.userId]) uniqueMembers[m.userId] = m; if (!uniqueMembers[m.userId]) uniqueMembers[m.userId] = m;
}); });
memberList = Object.keys(uniqueMembers).map((userId) => uniqueMembers[userId]); memberList = Object.keys(uniqueMembers).map((userId) => uniqueMembers[userId]);
// Descending sort on isPrivileged = true = 1 to isPrivileged = false = 0
memberList.sort((a, b) => { memberList.sort((a, b) => {
// TODO: should put admins at the top: we don't yet have that info if (a.isPrivileged === b.isPrivileged) {
if (a < b) { const aName = a.displayname || a.userId;
const bName = b.displayname || b.userId;
if (aName < bName) {
return -1; return -1;
} else if (a > b) { } else if (aName > bName) {
return 1; return 1;
} else { } else {
return 0; return 0;
} }
} else {
return a.isPrivileged ? -1 : 1;
}
}); });
const memberTiles = memberList.map((m) => { const memberTiles = memberList.map((m) => {