From 9745c4288d5d6765539e5446ab87bc3e3e794efc Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 18:05:41 +0000 Subject: [PATCH] Changes Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com> --- src/components/ShareButton.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/components/ShareButton.tsx b/src/components/ShareButton.tsx index bea6fe3..5a5d648 100644 --- a/src/components/ShareButton.tsx +++ b/src/components/ShareButton.tsx @@ -70,9 +70,27 @@ export function ShareButton({ variant = 'default', autoOpen, onHandleChange, onV streamRef.current = null; setHandle(null); setViewerCount(0); + onHandleChange?.(null); + onViewerCountChange?.(0); toast.info('Transmissão encerrada'); }; + // Auto-open dialog when requested by parent (in-XR HUD) + useEffect(() => { + if (autoOpen) setOpen(true); + }, [autoOpen]); + + // Expose start/stop via window so XR HUD can trigger from inside the scene + useEffect(() => { + (window as unknown as { __trackSteelStartLive?: () => void; __trackSteelStopLive?: () => void }).__trackSteelStartLive = () => { if (!handle) start(); }; + (window as unknown as { __trackSteelStopLive?: () => void }).__trackSteelStopLive = () => { if (handle) stop(); }; + return () => { + delete (window as unknown as { __trackSteelStartLive?: () => void }).__trackSteelStartLive; + delete (window as unknown as { __trackSteelStopLive?: () => void }).__trackSteelStopLive; + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [handle]); + // Cleanup on unmount useEffect(() => { return () => {