Refactor MemberSidebar user sorting logic

pull/1148/head
Ganni 2025-09-09 12:02:07 -04:00 committed by GitHub
parent 41f47a1a3f
commit 5dae2a95cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 21 deletions

View File

@ -98,30 +98,33 @@ function useEntries(
const sort = member?.nickname ?? u.username; const sort = member?.nickname ?? u.username;
const entry = [u, sort] as [User, string]; const entry = [u, sort] as [User, string];
if (!u.online || u.status?.presence === "Invisible") { if (member?.hasPermission(channel, "ViewChannel") || channel.recipient_ids?.includes(u._id)) {
categories.offline.push(entry); if (!u.online || u.status?.presence === "Invisible") {
} else { categories.offline.push(entry);
if (isServer) {
// Sort users into hoisted roles here.
if (member?.roles && roles) {
let success = false;
for (const role of roleList) {
if (member.roles.includes(role)) {
categories[role].push(entry);
success = true;
break;
}
}
if (success) return;
}
} else { } else {
// Sort users into "participants" list here. if (isServer) {
// For voice calls. // Sort users into hoisted roles here.
if (member?.roles && roles) {
let success = false;
for (const role of roleList) {
if (member.roles.includes(role)) {
categories[role].push(entry);
success = true;
break;
}
}
if (success) return;
}
} else {
// Sort users into "participants" list here.
// For voice calls.
}
categories.online.push(entry);
} }
categories.online.push(entry);
} }
}); });
Object.keys(categories).forEach((key) => Object.keys(categories).forEach((key) =>