From 5dae2a95cfe112247ea44753a5af41b9dfb9e218 Mon Sep 17 00:00:00 2001 From: Ganni Date: Tue, 9 Sep 2025 12:02:07 -0400 Subject: [PATCH] Refactor MemberSidebar user sorting logic --- .../navigation/right/MemberSidebar.tsx | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/components/navigation/right/MemberSidebar.tsx b/src/components/navigation/right/MemberSidebar.tsx index ef8d178b..5e54571f 100644 --- a/src/components/navigation/right/MemberSidebar.tsx +++ b/src/components/navigation/right/MemberSidebar.tsx @@ -98,30 +98,33 @@ function useEntries( const sort = member?.nickname ?? u.username; const entry = [u, sort] as [User, string]; - if (!u.online || u.status?.presence === "Invisible") { - categories.offline.push(entry); - } else { - 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; - } + if (member?.hasPermission(channel, "ViewChannel") || channel.recipient_ids?.includes(u._id)) { + if (!u.online || u.status?.presence === "Invisible") { + categories.offline.push(entry); } else { - // Sort users into "participants" list here. - // For voice calls. + 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 { + // Sort users into "participants" list here. + // For voice calls. + } + + categories.online.push(entry); } - - categories.online.push(entry); } + }); Object.keys(categories).forEach((key) =>