"use client"; import { ReactNode } from "react"; import { observer } from "mobx-react-lite"; import Image from "next/image"; import { useTheme } from "next-themes"; import useSWR from "swr"; // components import { LogoSpinner } from "@/components/common"; import { InstanceFailureView } from "@/components/instance"; // hooks import { useInstance, useUser } from "@/hooks/store"; // assets import PlaneBackgroundPatternDark from "public/auth/background-pattern-dark.svg"; import PlaneBackgroundPattern from "public/auth/background-pattern.svg"; import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text.png"; export const InstanceProvider = observer(({ children }: { children: ReactNode }) => { const { fetchInstanceInfo, instance, error } = useInstance(); const { fetchCurrentUser } = useUser(); const { resolvedTheme } = useTheme(); const patternBackground = resolvedTheme === "dark" ? PlaneBackgroundPatternDark : PlaneBackgroundPattern; useSWR("INSTANCE_INFO", () => fetchInstanceInfo(), { revalidateOnFocus: false, revalidateIfStale: false, errorRetryCount: 0, }); useSWR("CURRENT_USER", () => fetchCurrentUser()); if (!instance && !error) return (
); if (error) { return (
Plane Logo Plane
Plane background pattern
); } return <>{children}; });