fix(machines): remove artificial delay; always probe details immediately; fallback tri-state guarded only by fallback state
This commit is contained in:
parent
39726b360e
commit
3fce36d4e5
1 changed files with 5 additions and 6 deletions
|
|
@ -28,11 +28,13 @@ export function AdminMachineDetailsClient({ tenantId: _tenantId, machineId }: {
|
|||
const [loadError, setLoadError] = useState<string | null>(null)
|
||||
const [retryTick, setRetryTick] = useState(0)
|
||||
const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const shouldLoad = (single === undefined || single === null) && fallback === undefined && Boolean(machineId)
|
||||
const shouldLoad = fallback === undefined && Boolean(machineId)
|
||||
|
||||
useEffect(() => {
|
||||
if (!shouldLoad) return
|
||||
timer.current = setTimeout(async () => {
|
||||
(async () => {
|
||||
# immediate probe without delay
|
||||
|
||||
try {
|
||||
// 1) Tenta via Convex direto do browser (independe do servidor)
|
||||
const convexUrl = process.env.NEXT_PUBLIC_CONVEX_URL
|
||||
|
|
@ -82,10 +84,7 @@ export function AdminMachineDetailsClient({ tenantId: _tenantId, machineId }: {
|
|||
} catch (err) {
|
||||
setLoadError("Erro de rede ao carregar os dados da máquina.")
|
||||
}
|
||||
}, 600)
|
||||
return () => {
|
||||
if (timer.current) clearTimeout(timer.current)
|
||||
}
|
||||
|
||||
}, [shouldLoad, machineId, retryTick])
|
||||
|
||||
// Timeout de proteção: se depois de X segundos ainda estiver carregando e sem fallback, mostra erro claro
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue