From 6b77e83ca0a14111fb675338102f7b0683ea1fcb Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Sun, 22 Jun 2025 13:08:37 +0200 Subject: rename app provider to editor provider and add it to the editor instead --- apps/web/src/components/editor-provider.tsx | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 apps/web/src/components/editor-provider.tsx (limited to 'apps/web/src/components/editor-provider.tsx') diff --git a/apps/web/src/components/editor-provider.tsx b/apps/web/src/components/editor-provider.tsx new file mode 100644 index 00000000..fbae4c90 --- /dev/null +++ b/apps/web/src/components/editor-provider.tsx @@ -0,0 +1,42 @@ +"use client"; + +import { useEffect } from "react"; +import { Loader2 } from "lucide-react"; +import { useAppStore } from "@/stores/editor-store"; +import { usePanelStore } from "@/stores/panel-store"; + +interface EditorProviderProps { + children: React.ReactNode; +} + +export function EditorProvider({ children }: EditorProviderProps) { + const { isInitializing, isPanelsReady, initializeApp } = useAppStore(); + const { setInitialized } = usePanelStore(); + + useEffect(() => { + const initialize = async () => { + // Initialize the app + await initializeApp(); + + // Initialize panel store for future resize events + setInitialized(); + }; + + initialize(); + }, [initializeApp, setInitialized]); + + // Show loading screen while initializing + if (isInitializing || !isPanelsReady) { + return ( +
+
+ +

Loading editor...

+
+
+ ); + } + + // App is ready, render children + return <>{children}; +} -- cgit v1.3.1