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
This commit is contained in:
Michel Roegl-Brunner
2025-10-14 09:06:37 +02:00
parent e3fccca0fc
commit 08e0c82f4e
4 changed files with 5 additions and 5 deletions

View File

@@ -385,7 +385,7 @@ export function DownloadedScriptsTab({ onInstallScript }: DownloadedScriptsTabPr
);
}
if (!downloadedScripts || downloadedScripts.length === 0) {
if (!downloadedScripts?.length) {
return (
<div className="text-center py-12">
<div className="text-muted-foreground">

View File

@@ -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,

View File

@@ -571,7 +571,7 @@ export function ScriptsGrid({ onInstallScript }: ScriptsGridProps) {
);
}
if (!scriptsWithStatus || scriptsWithStatus.length === 0) {
if (!scriptsWithStatus?.length) {
return (
<div className="text-center py-12">
<div className="text-muted-foreground">

View File

@@ -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
}