From e79c165cbe19e2a51af25287f7c510c9db862f03 Mon Sep 17 00:00:00 2001 From: zbeyens Date: Mon, 25 Nov 2024 22:46:32 +0100 Subject: [PATCH] fix --- apps/www/src/components/block-viewer.tsx | 15 ++++++++++++++- apps/www/src/lib/registry.ts | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/www/src/components/block-viewer.tsx b/apps/www/src/components/block-viewer.tsx index c218924ed7..7e878c1198 100644 --- a/apps/www/src/components/block-viewer.tsx +++ b/apps/www/src/components/block-viewer.tsx @@ -115,6 +115,7 @@ function BlockViewerProvider({ >(highlightedFiles?.[0]?.target ?? null); const [isLoading, setIsLoading] = React.useState(false); const [isSettled, setIsSettled] = React.useState(false); + const [hasError, setHasError] = React.useState(false); // Add error state const resizablePanelRef = React.useRef(null); // Load code files when switching to code view @@ -124,6 +125,7 @@ function BlockViewerProvider({ highlightedFiles?.[1] && !highlightedFiles[1].content && !isLoading && + !hasError && !isSettled ) { const loadFiles = async () => { @@ -136,6 +138,9 @@ function BlockViewerProvider({ if (!activeFile && files?.length) { setActiveFile(files[0].target!); } + } catch (error) { + console.error('Failed to load files:', error); + setHasError(true); // Set error state to prevent retries } finally { setIsLoading(false); } @@ -144,7 +149,15 @@ function BlockViewerProvider({ }; void loadFiles(); } - }, [activeFile, highlightedFiles, isLoading, isSettled, item.name, view]); + }, [ + activeFile, + hasError, + highlightedFiles, + isLoading, + isSettled, + item.name, + view, + ]); return (