From 22954512047cbd4940b3a0e8b9ad39d90c66c94e Mon Sep 17 00:00:00 2001 From: perf3ct Date: Mon, 16 Jun 2025 16:57:45 +0000 Subject: [PATCH] feat(client): fix errors in the client about document slices --- frontend/src/components/Dashboard/Dashboard.tsx | 7 +++++-- .../src/components/GlobalSearchBar/GlobalSearchBar.tsx | 10 +++++++--- frontend/src/pages/SettingsPage.tsx | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Dashboard/Dashboard.tsx b/frontend/src/components/Dashboard/Dashboard.tsx index 99dbbef..dccae4e 100644 --- a/frontend/src/components/Dashboard/Dashboard.tsx +++ b/frontend/src/components/Dashboard/Dashboard.tsx @@ -200,6 +200,9 @@ const StatsCard: React.FC = ({ title, value, subtitle, icon: Ico const RecentDocuments: React.FC = ({ documents = [] }) => { const navigate = useNavigate(); const theme = useTheme(); + + // Ensure documents is always an array + const safeDocuments = Array.isArray(documents) ? documents : []; const getFileIcon = (mimeType?: string): React.ComponentType => { if (mimeType?.includes('pdf')) return PdfIcon; @@ -270,7 +273,7 @@ const RecentDocuments: React.FC = ({ documents = [] }) => /> - {documents.length === 0 ? ( + {safeDocuments.length === 0 ? ( = ({ documents = [] }) => ) : ( - {documents.slice(0, 5).map((doc, index) => { + {safeDocuments.slice(0, 5).map((doc, index) => { const FileIconComponent = getFileIcon(doc.mime_type); return ( diff --git a/frontend/src/components/GlobalSearchBar/GlobalSearchBar.tsx b/frontend/src/components/GlobalSearchBar/GlobalSearchBar.tsx index 0b6a221..3946248 100644 --- a/frontend/src/components/GlobalSearchBar/GlobalSearchBar.tsx +++ b/frontend/src/components/GlobalSearchBar/GlobalSearchBar.tsx @@ -275,8 +275,12 @@ const GlobalSearchBar: React.FC = ({ sx, ...props }) => { key={index} component="mark" sx={{ - backgroundColor: 'primary.light', - color: 'primary.contrastText', + backgroundColor: theme.palette.mode === 'light' + ? 'rgba(102, 126, 234, 0.2)' + : 'rgba(155, 181, 255, 0.25)', + color: theme.palette.mode === 'light' + ? theme.palette.primary.dark + : theme.palette.primary.light, padding: '0 2px', borderRadius: '2px', fontWeight: 600, @@ -288,7 +292,7 @@ const GlobalSearchBar: React.FC = ({ sx, ...props }) => { } return part; }); - }, []); + }, [theme.palette.mode, theme.palette.primary]); // Enhanced search with context snippets const generateContextSnippet = useCallback((filename: string, searchTerm: string): string => { diff --git a/frontend/src/pages/SettingsPage.tsx b/frontend/src/pages/SettingsPage.tsx index e9faa2f..9db313c 100644 --- a/frontend/src/pages/SettingsPage.tsx +++ b/frontend/src/pages/SettingsPage.tsx @@ -807,7 +807,7 @@ const WebDAVTabContent: React.FC = ({ )} - {syncStatus.errors && syncStatus.errors.length > 0 && ( + {syncStatus.errors && Array.isArray(syncStatus.errors) && syncStatus.errors.length > 0 && ( Recent Errors: