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