From 99bcbc9e9a1e56d567cb6aa96946fb94d12190a8 Mon Sep 17 00:00:00 2001 From: Johannes Date: Sun, 14 Sep 2025 18:19:28 +0200 Subject: [PATCH] feat: Add filtering for system files in FilePreview component - Implemented function in to filter out and similar system files. - Updated rendering logic to ensure ignored files are not displayed in the frontend. - Ensured consistency with backend filtering logic for a seamless user experience. This change improves the frontend by preventing unnecessary or system files from being --- frontend/src/components/FilePreview.js | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/frontend/src/components/FilePreview.js b/frontend/src/components/FilePreview.js index 1c28193..b4504c9 100644 --- a/frontend/src/components/FilePreview.js +++ b/frontend/src/components/FilePreview.js @@ -19,8 +19,40 @@ export function formatDuration(seconds) { return `${mins}:${secs.toString().padStart(2, '0')}`; } +// Hilfsfunktion zum Überprüfen ob eine Datei ignoriert werden soll +export function shouldIgnoreFile(filename) { + const ignoredFiles = [ + '.DS_Store', // macOS System file + 'Thumbs.db', // Windows Thumbnail cache + 'desktop.ini', // Windows Desktop configuration + '.gitignore', // Git configuration + '.gitkeep', // Git placeholder + 'config.yaml', // Configuration files + 'config.yml', + 'setup.yaml', + 'setup.yml', + '.htaccess', // Apache configuration + 'web.config', // IIS configuration + '.env', // Environment variables + '.env.local', + 'README.md', // Documentation + 'readme.txt', + 'license.txt', + 'LICENSE' + ]; + + return ignoredFiles.some(ignored => + filename.toLowerCase() === ignored.toLowerCase() + ); +} + // Datei-Vorschau-Komponente mit sofortiger Zoom-Skalierung und Loading-State export default function FilePreview({ file, zoom = 1, darkMode = false }) { + // Frühe Rückgabe für ignorierte Dateien + if (shouldIgnoreFile(file.name)) { + return null; + } + const [loaded, setLoaded] = React.useState(false); const width = file.width || 300; const height = file.height || 200; @@ -173,6 +205,10 @@ export default function FilePreview({ file, zoom = 1, darkMode = false }) { ); } + // Sonstige Datei: Prüfen ob ignoriert werden soll + if (shouldIgnoreFile(file.name)) { + return null; // Ignorierte Dateien nicht anzeigen + } // Sonstige Datei: Link return ( {file.name}