summaryrefslogtreecommitdiff
path: root/apps/web/src/components/editor-provider.tsx
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-06-22 13:08:37 +0200
committerMaze Winther <mazewinther@gmail.com>2025-06-22 13:08:37 +0200
commit6b77e83ca0a14111fb675338102f7b0683ea1fcb (patch)
tree9431533ce3d92cc7b3e8c7c014923c89d29b51c5 /apps/web/src/components/editor-provider.tsx
parentbe970248686c0af7d8506cba8c64bf507419da3d (diff)
downloadopencut-6b77e83ca0a14111fb675338102f7b0683ea1fcb.tar.gz
rename app provider to editor provider and add it to the editor instead
Diffstat (limited to 'apps/web/src/components/editor-provider.tsx')
-rw-r--r--apps/web/src/components/editor-provider.tsx42
1 files changed, 42 insertions, 0 deletions
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 (
+ <div className="h-screen w-screen flex items-center justify-center bg-background">
+ <div className="flex flex-col items-center gap-4">
+ <Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
+ <p className="text-sm text-muted-foreground">Loading editor...</p>
+ </div>
+ </div>
+ );
+ }
+
+ // App is ready, render children
+ return <>{children}</>;
+}