From e3e161fbea6111a3ea6d3be5e71ff2573934f7a4 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 8 Nov 2017 11:51:58 +0000 Subject: [PATCH 1/2] Order users in the group member list with admins first --- src/components/views/groups/GroupMemberList.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/views/groups/GroupMemberList.js b/src/components/views/groups/GroupMemberList.js index 8658ac19a5..8520ac3321 100644 --- a/src/components/views/groups/GroupMemberList.js +++ b/src/components/views/groups/GroupMemberList.js @@ -108,15 +108,9 @@ export default withMatrixClient(React.createClass({ if (!uniqueMembers[m.userId]) uniqueMembers[m.userId] = m; }); memberList = Object.keys(uniqueMembers).map((userId) => uniqueMembers[userId]); + // Descending sort on isPrivileged = true = 1 to isPrivileged = false = 0 memberList.sort((a, b) => { - // TODO: should put admins at the top: we don't yet have that info - if (a < b) { - return -1; - } else if (a > b) { - return 1; - } else { - return 0; - } + return b.isPrivileged - a.isPrivileged; }); const memberTiles = memberList.map((m) => { From e2a0cba6cb4e42e10602ab604e7c560df1e31995 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 8 Nov 2017 13:57:38 +0000 Subject: [PATCH 2/2] If group member privilege level is equal, disambiguate with displayname or userId --- src/components/views/groups/GroupMemberList.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/views/groups/GroupMemberList.js b/src/components/views/groups/GroupMemberList.js index 8520ac3321..063051625f 100644 --- a/src/components/views/groups/GroupMemberList.js +++ b/src/components/views/groups/GroupMemberList.js @@ -110,7 +110,19 @@ export default withMatrixClient(React.createClass({ memberList = Object.keys(uniqueMembers).map((userId) => uniqueMembers[userId]); // Descending sort on isPrivileged = true = 1 to isPrivileged = false = 0 memberList.sort((a, b) => { - return b.isPrivileged - a.isPrivileged; + if (a.isPrivileged === b.isPrivileged) { + const aName = a.displayname || a.userId; + const bName = b.displayname || b.userId; + if (aName < bName) { + return -1; + } else if (aName > bName) { + return 1; + } else { + return 0; + } + } else { + return a.isPrivileged ? -1 : 1; + } }); const memberTiles = memberList.map((m) => {