import { Card, CardContent, Button, Tooltip, TooltipContent, TooltipTrigger, } from "@tensamin/ui"; import { useEffect, useState } from "react"; import MuteButton from "./buttons/mute"; import DeafButton from "./buttons/deaf"; import ScreenshareButton from "./buttons/screenshare"; import LeaveButton from "./buttons/leave"; import { setCallIsPopout, setUsersInFocusedViewHidden, stopWatchingFocusedStream, triggerCallLayoutCalculation, useCall, } from "../store"; import InviteButton from "./buttons/invite"; import { ChevronDown, ChevronUp, Maximize, Minimize, ScreenShareOff, SquareArrowOutDownLeft, SquareArrowOutUpRight, } from "lucide-react"; import { useStorage } from "@tensamin/storage/context"; export default function Actions() { const sharedClasses = "w-14 h-10"; const sharedIconSize = 15; const view = useCall((state) => state.view); const focusedParticipantId = useCall((state) => state.focusedParticipantId); const watchedStreamParticipantIds = useCall( (state) => state.watchedStreamParticipantIds, ); const isWatchingFocusedStream = view === "focused" && focusedParticipantId != null && watchedStreamParticipantIds.includes(focusedParticipantId); const { load } = useStorage(); const [ownId, setOwnId] = useState(0); useEffect(() => { load("user_id").then(setOwnId); }, [load]); // Fullscreen stuff const callIsPopout = useCall((state) => state.callIsPopout); const callIsFullscreen = useCall((state) => state.callIsFullscreen); const screenRef = useCall((state) => state.screenRef); const [portalContainer, setPortalContainer] = useState(); useEffect(() => { setPortalContainer(screenRef?.current ?? undefined); }, [screenRef]); const toggleFullscreen = async () => { const screen = screenRef?.current; const fullscreenDocument = screen?.ownerDocument ?? document; if (callIsFullscreen) { await fullscreenDocument.exitFullscreen().catch(() => undefined); } else { await screen?.requestFullscreen().catch(() => undefined); } triggerCallLayoutCalculation(); }; // Hide users in focused view const usersInFocusedViewHidden = useCall( (state) => state.usersInFocusedViewHidden, ); return (
{view === "focused" && ( setUsersInFocusedViewHidden(!usersInFocusedViewHidden) } variant="link" className="w-11 h-11 p-0! ml-3 text-foreground" > {usersInFocusedViewHidden ? ( ) : ( )} } /> Hide users )}
{isWatchingFocusedStream && focusedParticipantId !== ownId ? ( stopWatchingFocusedStream()} > } /> Stop watching ) : ( )}
setCallIsPopout(!callIsPopout)} variant="link" className="w-11 h-11 p-0! text-foreground" > {callIsPopout ? ( ) : ( )} } /> Popout { void toggleFullscreen(); }} variant="link" className="w-11 h-11 p-0! mr-3 text-foreground" > {callIsFullscreen ? ( ) : ( )} } /> Fullscreen
); }