feat(client): fix errors in the client about document slices
This commit is contained in:
parent
12c5ca37ea
commit
2295451204
|
|
@ -201,6 +201,9 @@ const RecentDocuments: React.FC<RecentDocumentsProps> = ({ documents = [] }) =>
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
|
// Ensure documents is always an array
|
||||||
|
const safeDocuments = Array.isArray(documents) ? documents : [];
|
||||||
|
|
||||||
const getFileIcon = (mimeType?: string): React.ComponentType<any> => {
|
const getFileIcon = (mimeType?: string): React.ComponentType<any> => {
|
||||||
if (mimeType?.includes('pdf')) return PdfIcon;
|
if (mimeType?.includes('pdf')) return PdfIcon;
|
||||||
if (mimeType?.includes('image')) return ImageIcon;
|
if (mimeType?.includes('image')) return ImageIcon;
|
||||||
|
|
@ -270,7 +273,7 @@ const RecentDocuments: React.FC<RecentDocumentsProps> = ({ documents = [] }) =>
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{documents.length === 0 ? (
|
{safeDocuments.length === 0 ? (
|
||||||
<Box sx={{ textAlign: 'center', py: 4 }}>
|
<Box sx={{ textAlign: 'center', py: 4 }}>
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
width: 64,
|
width: 64,
|
||||||
|
|
@ -298,7 +301,7 @@ const RecentDocuments: React.FC<RecentDocumentsProps> = ({ documents = [] }) =>
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<List sx={{ p: 0 }}>
|
<List sx={{ p: 0 }}>
|
||||||
{documents.slice(0, 5).map((doc, index) => {
|
{safeDocuments.slice(0, 5).map((doc, index) => {
|
||||||
const FileIconComponent = getFileIcon(doc.mime_type);
|
const FileIconComponent = getFileIcon(doc.mime_type);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -275,8 +275,12 @@ const GlobalSearchBar: React.FC<GlobalSearchBarProps> = ({ sx, ...props }) => {
|
||||||
key={index}
|
key={index}
|
||||||
component="mark"
|
component="mark"
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: 'primary.light',
|
backgroundColor: theme.palette.mode === 'light'
|
||||||
color: 'primary.contrastText',
|
? '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',
|
padding: '0 2px',
|
||||||
borderRadius: '2px',
|
borderRadius: '2px',
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
|
|
@ -288,7 +292,7 @@ const GlobalSearchBar: React.FC<GlobalSearchBarProps> = ({ sx, ...props }) => {
|
||||||
}
|
}
|
||||||
return part;
|
return part;
|
||||||
});
|
});
|
||||||
}, []);
|
}, [theme.palette.mode, theme.palette.primary]);
|
||||||
|
|
||||||
// Enhanced search with context snippets
|
// Enhanced search with context snippets
|
||||||
const generateContextSnippet = useCallback((filename: string, searchTerm: string): string => {
|
const generateContextSnippet = useCallback((filename: string, searchTerm: string): string => {
|
||||||
|
|
|
||||||
|
|
@ -807,7 +807,7 @@ const WebDAVTabContent: React.FC<WebDAVTabContentProps> = ({
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{syncStatus.errors && syncStatus.errors.length > 0 && (
|
{syncStatus.errors && Array.isArray(syncStatus.errors) && syncStatus.errors.length > 0 && (
|
||||||
<Alert severity="error" sx={{ mt: 2 }}>
|
<Alert severity="error" sx={{ mt: 2 }}>
|
||||||
<Typography variant="body2" sx={{ mb: 1 }}>
|
<Typography variant="body2" sx={{ mb: 1 }}>
|
||||||
<strong>Recent Errors:</strong>
|
<strong>Recent Errors:</strong>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue