Fix issue #22: Gallery filter counts disappearing and upload errors
This commit comprehensively addresses the persistent issues reported in #22: 1. Gallery Filter Bug - Counts Disappearing - Root cause: Frontend fetched filtered photos from backend, then calculated counts from already-filtered data - Fix: Always fetch ALL photos, apply filtering client-side only - Benefits: Counts always accurate, filters work correctly in combo - Changed: frontend/src/components/gallery/GalleryView.tsx:76 2. Upload ENOENT Errors - Root cause: /tmp/uploads/ directory assumed to exist - Fix: Verify and create temp directory before multer initialization - Changed: backend/src/routes/gallery.js:814-825 3. Upload "Not Iterable" Errors - Root cause: normalizeFiles() didn't handle null/edge cases - Fix: Enhanced error handling with try-catch and graceful degradation - Changed: backend/src/services/photoProcessor.js:10-52 4. Enhanced Upload Debugging - Added file existence verification before copy operations - Improved temp file cleanup (properly handle ENOENT) - Comprehensive error logging with full context - Changed: backend/src/services/photoProcessor.js:108-233 Technical Details: - Gallery filtering now entirely client-side (simpler architecture) - Upload error messages now include full diagnostic context - Temp file cleanup handles ENOENT gracefully (expected scenario) - All fixes preserve backward compatibility Testing: - Gallery filters: Verify counts stay visible when filtering - Uploads: Test single/batch uploads, check temp cleanup - Logs: Verify detailed error context on failures See ISSUE_22_FIX_SUMMARY.md for complete analysis and testing guide. Fixes #22
This commit is contained in:
@@ -71,8 +71,9 @@ export const GalleryView: React.FC<GalleryViewProps> = ({ slug, event }) => {
|
||||
setGuestId(storedGuestId);
|
||||
}, []);
|
||||
|
||||
// Fetch photos with filter support
|
||||
const { data, isLoading, error, refetch } = useGalleryPhotos(slug, filterType, guestId);
|
||||
// Fetch photos WITHOUT filter (always get all photos, filter on frontend)
|
||||
// This ensures counts are always calculated from the full dataset
|
||||
const { data, isLoading, error, refetch } = useGalleryPhotos(slug, 'all', guestId);
|
||||
|
||||
// Set protection level when data is available
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user