import { useNavigate } from "react-router-dom"; import { X, Mic } from "lucide-react"; import { useAutoplayStore } from "@/stores/autoplay-store"; import { useDownloadUrl } from "@/hooks/use-download-url"; import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { Small } from "@/components/ui/typography"; import { getInitials } from "@/lib/utils"; import { useNetwork } from "@/hooks/use-networks"; interface AutoplayOverlayProps { networkId: string; } export function AutoplayOverlay({ networkId }: AutoplayOverlayProps) { const activeParticle = useAutoplayStore((s) => s.activeParticle); const streamId = useAutoplayStore((s) => s.streamId); const stop = useAutoplayStore((s) => s.stop); const { data: url } = useDownloadUrl(activeParticle?.properties.object_id); const navigate = useNavigate(); const network = useNetwork(networkId); if (!activeParticle || !url) return null; const isVideo = activeParticle.properties.mime_type?.startsWith("video/"); const creator = network?.humans?.find((h) => h.id === activeParticle.created_by_human_id); const senderInitials = creator ? getInitials(creator.email) : activeParticle.created_by_human_id.slice(0, 2).toUpperCase(); const senderName = creator?.email_prefix ?? activeParticle.created_by_human_id; const handleClick = () => { stop(); if (streamId) { navigate(`/${networkId}/${streamId}`); } }; const closeButton = ( ); const senderBar = (
{senderInitials} {senderName}
); return (
{isVideo ? (
{closeButton}
) : (
{closeButton}
{senderInitials}
{senderName}
)}
); }