"use client"; import { useEffect, useRef, useState } from "react"; import { useSdk, useChannel } from "@lynkd/messaging-inbox-sdk"; import { useUi } from "@/lib/ui-state"; import { Avatar } from "@/components/ui/primitives"; import { Mic, MicOff, Video, VideoOff, MonitorUp, PhoneOff } from "lucide-react"; import clsx from "clsx"; export function HuddleBar() { const { huddleChannelId, endHuddle } = useUi(); const channel = useChannel(huddleChannelId ?? null); const { userById } = useSdk(); const [muted, setMuted] = useState(false); const [video, setVideo] = useState(false); const [sharing, setSharing] = useState(false); const [seconds, setSeconds] = useState(0); const startRef = useRef(0); useEffect(() => { if (!huddleChannelId) return; setSeconds(0); setMuted(false); setVideo(false); setSharing(false); startRef.current = Date.now(); const t = setInterval(() => setSeconds(Math.floor((Date.now() - startRef.current) / 1000)), 1000); return () => clearInterval(t); }, [huddleChannelId]); if (!huddleChannelId || !channel) return null; const members = channel.memberIds.slice(0, 4).map((id) => userById(id)).filter(Boolean); const total = channel.memberIds.length; const mmss = `${String(Math.floor(seconds / 60)).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`; return (
setMuted((m) => !m)} /> setVideo((v) => !v)} /> setSharing((s) => !s)} />
); } function HuddleBtn({ icon: Icon, label, onClick, active }: { icon: typeof Mic; label: string; onClick: () => void; active?: boolean }) { return ( ); }