diff --git a/apps/dashboard/src/components/theme-toggle.tsx b/apps/dashboard/src/components/theme-toggle.tsx index b29b7dd163..3b7c2c1978 100644 --- a/apps/dashboard/src/components/theme-toggle.tsx +++ b/apps/dashboard/src/components/theme-toggle.tsx @@ -22,6 +22,11 @@ export default function ThemeToggle() { return; } + if (typeof document.startViewTransition !== "function") { + setTheme(nextTheme); + return; + } + document.documentElement.classList.add("vt-disable-transitions"); const transition = document.startViewTransition(() => { diff --git a/apps/dashboard/src/hooks/use-wait-for-idle.tsx b/apps/dashboard/src/hooks/use-wait-for-idle.tsx index f012228e54..be7552757f 100644 --- a/apps/dashboard/src/hooks/use-wait-for-idle.tsx +++ b/apps/dashboard/src/hooks/use-wait-for-idle.tsx @@ -5,10 +5,15 @@ export function useWaitForIdle(min = 0, max = 5000) { useEffect(() => { let cancelled = false; setTimeout(() => { - requestIdleCallback(() => { + const cb = () => { if (cancelled) return; setHasWaited(true); - }, { timeout: max - min }); + }; + if (typeof requestIdleCallback === "function") { + requestIdleCallback(cb, { timeout: max - min }); + } else { + setTimeout(cb, max - min); + } }, min); return () => { cancelled = true;