From 5dbd6929e6356866155ae2ef7b927a6670279730 Mon Sep 17 00:00:00 2001 From: Arjun Patel Date: Tue, 9 Jun 2026 11:47:35 -0700 Subject: [PATCH] refactor: more readable code --- .../src/features/particles/stream-top-bar.tsx | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/js/desktop/src/features/particles/stream-top-bar.tsx b/js/desktop/src/features/particles/stream-top-bar.tsx index 1306f6b..29f12c2 100644 --- a/js/desktop/src/features/particles/stream-top-bar.tsx +++ b/js/desktop/src/features/particles/stream-top-bar.tsx @@ -276,10 +276,14 @@ function MembersIndicator({ const userId = useAuthStore((s) => s.user?.id); const humans = network?.humans ?? []; - const othersIds = - visibility.mode === 'network' - ? [] - : visibility.humanIds.filter((id) => id != userId); + const isNetworkWide = visibility.mode === 'network'; + const allMemberIds = visibility.humanIds; + const othersIds = isNetworkWide + ? [] + : allMemberIds.filter((id) => id != userId); + + const isPrivate = othersIds.length == 0; + const shownMembers = othersIds .slice(0, 3) .map((id) => humans.find((h) => h.id === id)) @@ -293,12 +297,17 @@ function MembersIndicator({ onClick={onClick} className="no-drag flex items-center gap-1.5 rounded-full bg-white/5 px-2 py-1 text-xs text-white/70 backdrop-blur-sm transition-colors hover:bg-white/10" > - {visibility.mode === 'network' ? ( + {isNetworkWide ? ( <> Everyone - ) : othersIds.length > 0 ? ( + ) : isPrivate ? ( + <> + + Private + + ) : ( <> {shownMembers.map((human) => ( @@ -313,18 +322,13 @@ function MembersIndicator({ +{overflow} )} - ) : ( - <> - - Private - )} - {visibility.mode === 'network' + {isNetworkWide ? `Everyone in ${network?.name ?? 'network'}` - : `${othersIds.length + 1} ${othersIds.length + 1 === 1 ? 'member' : 'members'}`} + : `${allMemberIds.length} ${allMemberIds.length === 1 ? 'member' : 'members'}`} );