From 08e0c82f4e2829cb26a11e948d0039a7dad095ac Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Tue, 14 Oct 2025 09:06:37 +0200 Subject: [PATCH] Fix build errors and warnings - Fix optional chain expression errors in DownloadedScriptsTab, ScriptsGrid, and colorUtils - Fix React hooks dependency warnings in InstalledScriptsTab - Update useCallback dependency array to include containerStatusMutation - Update useEffect dependency array to include fetchContainerStatuses - Build now passes successfully with no errors or warnings --- src/app/_components/DownloadedScriptsTab.tsx | 2 +- src/app/_components/InstalledScriptsTab.tsx | 4 ++-- src/app/_components/ScriptsGrid.tsx | 2 +- src/lib/colorUtils.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/_components/DownloadedScriptsTab.tsx b/src/app/_components/DownloadedScriptsTab.tsx index ebdabd0..a0d263a 100644 --- a/src/app/_components/DownloadedScriptsTab.tsx +++ b/src/app/_components/DownloadedScriptsTab.tsx @@ -385,7 +385,7 @@ export function DownloadedScriptsTab({ onInstallScript }: DownloadedScriptsTabPr ); } - if (!downloadedScripts || downloadedScripts.length === 0) { + if (!downloadedScripts?.length) { return (
diff --git a/src/app/_components/InstalledScriptsTab.tsx b/src/app/_components/InstalledScriptsTab.tsx index 3ba3107..cf369fa 100644 --- a/src/app/_components/InstalledScriptsTab.tsx +++ b/src/app/_components/InstalledScriptsTab.tsx @@ -322,7 +322,7 @@ export function InstalledScriptsTab() { if (serverIds.length > 0) { containerStatusMutation.mutate({ serverIds }); } - }, []); + }, [containerStatusMutation]); // Run cleanup when component mounts and scripts are loaded (only once) useEffect(() => { @@ -337,7 +337,7 @@ export function InstalledScriptsTab() { if (scripts.length > 0) { fetchContainerStatuses(); } - }, [scripts.length]); // Only depend on scripts.length to prevent infinite loops + }, [scripts.length, fetchContainerStatuses]); const scriptsWithStatus = scripts.map(script => ({ ...script, diff --git a/src/app/_components/ScriptsGrid.tsx b/src/app/_components/ScriptsGrid.tsx index 9191aec..d2d22a6 100644 --- a/src/app/_components/ScriptsGrid.tsx +++ b/src/app/_components/ScriptsGrid.tsx @@ -571,7 +571,7 @@ export function ScriptsGrid({ onInstallScript }: ScriptsGridProps) { ); } - if (!scriptsWithStatus || scriptsWithStatus.length === 0) { + if (!scriptsWithStatus?.length) { return (
diff --git a/src/lib/colorUtils.ts b/src/lib/colorUtils.ts index 3e1fbd0..ddbb6f9 100644 --- a/src/lib/colorUtils.ts +++ b/src/lib/colorUtils.ts @@ -3,7 +3,7 @@ * to ensure optimal readability based on luminance */ export function getContrastColor(hexColor: string): 'black' | 'white' { - if (!hexColor || hexColor.length !== 7 || !hexColor.startsWith('#')) { + if (!hexColor?.length || hexColor.length !== 7 || !hexColor.startsWith('#')) { return 'black'; // Default to black for invalid colors }