🚀 Auto-deploy: melhoria no snap e medição AR em 25/05/2026 00:56:37
This commit is contained in:
@@ -640,6 +640,7 @@ export default function MeetingRoom() {
|
|||||||
|
|
||||||
// Estados do Lobby
|
// Estados do Lobby
|
||||||
const [inRoom, setInRoom] = useState(false);
|
const [inRoom, setInRoom] = useState(false);
|
||||||
|
const [isConnecting, setIsConnecting] = useState(false);
|
||||||
const [name, setName] = useState('');
|
const [name, setName] = useState('');
|
||||||
const [cargo, setCargo] = useState('');
|
const [cargo, setCargo] = useState('');
|
||||||
const [empresa, setEmpresa] = useState('');
|
const [empresa, setEmpresa] = useState('');
|
||||||
@@ -713,7 +714,7 @@ export default function MeetingRoom() {
|
|||||||
// --- ESCUTA DO LOBBY EM TEMPO REAL ---
|
// --- ESCUTA DO LOBBY EM TEMPO REAL ---
|
||||||
// Conecta ao canal antes do lobby finalizar para ler assentos e avatares ocupados na sala digitada
|
// Conecta ao canal antes do lobby finalizar para ler assentos e avatares ocupados na sala digitada
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!inputRoomId || inputRoomId.trim().length < 3) {
|
if (!inputRoomId || inputRoomId.trim().length < 3 || inRoom || isConnecting) {
|
||||||
setPeers({});
|
setPeers({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -747,9 +748,11 @@ export default function MeetingRoom() {
|
|||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
console.log(`🔌 [Lobby Watcher] Desinscrevendo escuta passiva da sala: ${roomIdUpper}`);
|
||||||
tempChannel.unsubscribe();
|
tempChannel.unsubscribe();
|
||||||
|
supabase.removeChannel(tempChannel);
|
||||||
};
|
};
|
||||||
}, [inputRoomId, inRoom]);
|
}, [inputRoomId, inRoom, isConnecting]);
|
||||||
|
|
||||||
// Envia as atualizações de apresentação via Broadcast para a sala inteira
|
// Envia as atualizações de apresentação via Broadcast para a sala inteira
|
||||||
const handlePresentationChange = (updatedFields: Partial<PresentationState>) => {
|
const handlePresentationChange = (updatedFields: Partial<PresentationState>) => {
|
||||||
@@ -785,6 +788,10 @@ export default function MeetingRoom() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ativa o estado de conexão e aguarda 120ms para a escuta do lobby se desmontar totalmente
|
||||||
|
setIsConnecting(true);
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 120));
|
||||||
|
|
||||||
const finalRoomId = targetRoomId.trim().toUpperCase() || Math.random().toString(36).substring(3, 8).toUpperCase();
|
const finalRoomId = targetRoomId.trim().toUpperCase() || Math.random().toString(36).substring(3, 8).toUpperCase();
|
||||||
setRoomCode(finalRoomId);
|
setRoomCode(finalRoomId);
|
||||||
|
|
||||||
@@ -877,9 +884,11 @@ export default function MeetingRoom() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setInRoom(true);
|
setInRoom(true);
|
||||||
|
setIsConnecting(false);
|
||||||
toast.success(`Entrou na sala de reunião: ${finalRoomId}`);
|
toast.success(`Entrou na sala de reunião: ${finalRoomId}`);
|
||||||
navigate(`/meeting/${finalRoomId}`, { replace: true });
|
navigate(`/meeting/${finalRoomId}`, { replace: true });
|
||||||
} else if (status === 'CHANNEL_ERROR') {
|
} else if (status === 'CHANNEL_ERROR') {
|
||||||
|
setIsConnecting(false);
|
||||||
toast.error('Erro ao conectar ao canal de reuniões.');
|
toast.error('Erro ao conectar ao canal de reuniões.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -905,6 +914,7 @@ export default function MeetingRoom() {
|
|||||||
await supabase.removeChannel(channelRef.current);
|
await supabase.removeChannel(channelRef.current);
|
||||||
}
|
}
|
||||||
setInRoom(false);
|
setInRoom(false);
|
||||||
|
setIsConnecting(false);
|
||||||
setPeers({});
|
setPeers({});
|
||||||
setChatMessages([]);
|
setChatMessages([]);
|
||||||
navigate('/');
|
navigate('/');
|
||||||
|
|||||||
Reference in New Issue
Block a user