show private for sterams with no other members
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
CircleDot,
|
||||
EllipsisVertical,
|
||||
Pencil,
|
||||
Lock,
|
||||
Globe,
|
||||
Trash2,
|
||||
} from 'lucide-react';
|
||||
@@ -271,17 +272,19 @@ function MembersIndicator({
|
||||
}) {
|
||||
const network = useNetwork(networkId);
|
||||
const visibility = parseVisibleTo(streamParticle.visible_to, networkId);
|
||||
|
||||
const userId = useAuthStore((s) => s.user?.id);
|
||||
const humans = network?.humans ?? [];
|
||||
|
||||
const memberIds =
|
||||
const othersIds =
|
||||
visibility.mode === 'network'
|
||||
? humans.map((h) => h.id)
|
||||
: visibility.humanIds;
|
||||
const shownMembers = memberIds
|
||||
? []
|
||||
: visibility.humanIds.filter((id) => id != userId);
|
||||
const shownMembers = othersIds
|
||||
.slice(0, 3)
|
||||
.map((id) => humans.find((h) => h.id === id))
|
||||
.filter((h): h is NonNullable<typeof h> => !!h);
|
||||
const overflow = memberIds.length - shownMembers.length;
|
||||
const overflow = othersIds.length - othersIds.length;
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
@@ -295,7 +298,7 @@ function MembersIndicator({
|
||||
<Globe className="size-3 text-white/50" />
|
||||
<span>Everyone</span>
|
||||
</>
|
||||
) : (
|
||||
) : othersIds.length > 0 ? (
|
||||
<>
|
||||
<AvatarGroup>
|
||||
{shownMembers.map((human) => (
|
||||
@@ -310,13 +313,18 @@ function MembersIndicator({
|
||||
<span className="text-white/50">+{overflow}</span>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Lock className="size-3 text-white/50" />
|
||||
<span>Private</span>
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
{visibility.mode === 'network'
|
||||
? `Everyone in ${network?.name ?? 'network'}`
|
||||
: `${memberIds.length} ${memberIds.length === 1 ? 'member' : 'members'}`}
|
||||
: `${othersIds.length + 1} ${othersIds.length + 1 === 1 ? 'member' : 'members'}`}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user