From 9a3b59baf20932151c56aaa8e314d39c96fc1626 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Wed, 10 Jun 2026 20:53:22 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Auto-deploy:=20melhoria=20no=20s?= =?UTF-8?q?nap=20e=20medi=C3=A7=C3=A3o=20AR=20em=2010/06/2026=2020:53:22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/XRSession.tsx | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/pages/XRSession.tsx b/src/pages/XRSession.tsx index 562c5c7..6c17323 100644 --- a/src/pages/XRSession.tsx +++ b/src/pages/XRSession.tsx @@ -7,7 +7,7 @@ import { xrStore as store } from '@/stores/useXRStore'; import * as THREE from 'three'; import { useModelStore } from '@/stores/useModelStore'; import { toast } from 'sonner'; -import { ArrowLeft, Download, QrCode, Crosshair, Home, Glasses } from 'lucide-react'; +import { ArrowLeft, Download, QrCode, Crosshair, Home, Glasses, Loader2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { generateMarkerDownloadURL } from '@/lib/trackingMarker'; import { XRHud } from '@/components/XRHud'; @@ -1069,11 +1069,13 @@ const XRSession = () => { session.addEventListener('end', () => { console.log('[XR] ❌ Sessão AR encerrada'); setInXR(false); + setHasClickedEnter(false); + navigate('/viewer'); }); } }); return unsubscribe; - }, [inXR, setAnchorMode]); + }, [inXR, setAnchorMode, navigate]); // Flag que indica que o usuário pediu para entrar no AR (enterAR chamado). // Usada para bloquear o auto-return durante o onboarding do WebXR. @@ -1099,20 +1101,6 @@ const XRSession = () => { toast.success('Marcador baixado — Imprima em 15×15cm'); }, []); - // Auto-return to viewer if user exits AR session - useEffect(() => { - // Don't auto-return while we're waiting for the XR onboarding dialog to complete - if (hasClickedEnter && !inXR) { - const timer = setTimeout(() => { - // Only return if the session is truly absent AND we're not in the middle of entering AR - if (!store.getState().session) { - navigate('/viewer'); - } - }, 2000); - return () => clearTimeout(timer); - } - }, [inXR, hasClickedEnter, navigate]); - if (!model) return null; return ( @@ -1315,6 +1303,7 @@ const XRSession = () => {