diff --git a/packages/app/src/pages/layout.tsx b/packages/app/src/pages/layout.tsx index b46758049..816793753 100644 --- a/packages/app/src/pages/layout.tsx +++ b/packages/app/src/pages/layout.tsx @@ -1614,9 +1614,7 @@ export default function Layout(props: ParentProps) { } > -
- {header()} -
+
{header()}
): Platform => ({ length(): Promise } - const WRITE_DEBOUNCE_MS = 250 + const WRITE_DEBOUNCE_MS = 250 - const storeCache = new Map>() - const apiCache = new Map Promise }>() - const memoryCache = new Map() + const storeCache = new Map>() + const apiCache = new Map Promise }>() + const memoryCache = new Map() - const flushAll = async () => { - const apis = Array.from(apiCache.values()) - await Promise.all(apis.map((api) => api.flush().catch(() => undefined))) + const flushAll = async () => { + const apis = Array.from(apiCache.values()) + await Promise.all(apis.map((api) => api.flush().catch(() => undefined))) + } + + if ("addEventListener" in globalThis) { + const handleVisibility = () => { + if (document.visibilityState !== "hidden") return + void flushAll() } - if ("addEventListener" in globalThis) { - const handleVisibility = () => { - if (document.visibilityState !== "hidden") return - void flushAll() - } - - window.addEventListener("pagehide", () => void flushAll()) - document.addEventListener("visibilitychange", handleVisibility) - } + window.addEventListener("pagehide", () => void flushAll()) + document.addEventListener("visibilitychange", handleVisibility) + } const createMemoryStore = () => { const data = new Map()