🚀 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
|
||||
const [inRoom, setInRoom] = useState(false);
|
||||
const [isConnecting, setIsConnecting] = useState(false);
|
||||
const [name, setName] = useState('');
|
||||
const [cargo, setCargo] = useState('');
|
||||
const [empresa, setEmpresa] = useState('');
|
||||
@@ -713,7 +714,7 @@ export default function MeetingRoom() {
|
||||
// --- ESCUTA DO LOBBY EM TEMPO REAL ---
|
||||
// Conecta ao canal antes do lobby finalizar para ler assentos e avatares ocupados na sala digitada
|
||||
useEffect(() => {
|
||||
if (!inputRoomId || inputRoomId.trim().length < 3) {
|
||||
if (!inputRoomId || inputRoomId.trim().length < 3 || inRoom || isConnecting) {
|
||||
setPeers({});
|
||||
return;
|
||||
}
|
||||
@@ -747,9 +748,11 @@ export default function MeetingRoom() {
|
||||
.subscribe();
|
||||
|
||||
return () => {
|
||||
console.log(`🔌 [Lobby Watcher] Desinscrevendo escuta passiva da sala: ${roomIdUpper}`);
|
||||
tempChannel.unsubscribe();
|
||||
supabase.removeChannel(tempChannel);
|
||||
};
|
||||
}, [inputRoomId, inRoom]);
|
||||
}, [inputRoomId, inRoom, isConnecting]);
|
||||
|
||||
// Envia as atualizações de apresentação via Broadcast para a sala inteira
|
||||
const handlePresentationChange = (updatedFields: Partial<PresentationState>) => {
|
||||
@@ -785,6 +788,10 @@ export default function MeetingRoom() {
|
||||
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();
|
||||
setRoomCode(finalRoomId);
|
||||
|
||||
@@ -877,9 +884,11 @@ export default function MeetingRoom() {
|
||||
}
|
||||
|
||||
setInRoom(true);
|
||||
setIsConnecting(false);
|
||||
toast.success(`Entrou na sala de reunião: ${finalRoomId}`);
|
||||
navigate(`/meeting/${finalRoomId}`, { replace: true });
|
||||
} else if (status === 'CHANNEL_ERROR') {
|
||||
setIsConnecting(false);
|
||||
toast.error('Erro ao conectar ao canal de reuniões.');
|
||||
}
|
||||
});
|
||||
@@ -905,6 +914,7 @@ export default function MeetingRoom() {
|
||||
await supabase.removeChannel(channelRef.current);
|
||||
}
|
||||
setInRoom(false);
|
||||
setIsConnecting(false);
|
||||
setPeers({});
|
||||
setChatMessages([]);
|
||||
navigate('/');
|
||||
|
||||
Reference in New Issue
Block a user