Skip to content

Add filename search filter to photo gallery - #11

Merged
T-One merged 1 commit into
mainfrom
claude/add-raw-file-search-I5AA9
Mar 1, 2026
Merged

T-One merged 1 commit into
mainfrom
claude/add-raw-file-search-I5AA9

Conversation

@T-One

@T-One T-One commented Mar 1, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds a filename search feature to the photo gallery, allowing users to filter photos by searching for substrings in their filenames. The search includes a debounced input field with a clear button and integrates seamlessly with existing filters.

Key Changes

Frontend:

  • Added filename_search filter state to the filters object
  • Implemented a debounced search input (300ms delay) with useRef to manage the timer
  • Created a new search input UI component with search icon, placeholder text, and clear button
  • Updated the Toolbar component to accept an onClearAll callback for resetting all filters including the search input
  • Modified usePhotos hook to include filename_search in API query parameters

Backend:

  • Extended get_photos() function in database.py to support case-insensitive filename substring search using SQL LIKE with proper escaping
  • Extended get_photo_count() function to apply the same filename filter for accurate count results
  • Added filename_search query parameter to both /photos and /photos/count endpoints in main.py with validation (max 255 characters)

Implementation Details

  • The search input uses a 300ms debounce to avoid excessive API calls while typing
  • SQL LIKE queries properly escape special characters (% and _) to prevent unintended wildcard matching
  • The clear button appears only when there's text in the search field
  • The search filter is included in the "Clear All" functionality to reset all filters at once
  • The search input state is separate from the filter state to allow real-time UI updates while debouncing the actual filter application

https://claude.ai/code/session_01Rz1mnmLosnStLBTjSv5Wx4

Adds a debounced filename search box in the app header (next to the
Refresh button) that filters RAW files by name substring match.

- backend/database.py: add `filename_search` LIKE param to get_photos()
  and get_photo_count()
- backend/main.py: expose `filename_search` query param on /api/photos
  and /api/photos/count endpoints
- frontend/src/hooks/usePhotos.js: include filename_search in buildParams
- frontend/src/App.jsx: add debounced search input (300ms) with clear
  button; filename_search wired into filters state
- frontend/src/components/Toolbar.jsx: include filename_search in
  hasFilters check; support onClearAll prop to also reset search input

https://claude.ai/code/session_01Rz1mnmLosnStLBTjSv5Wx4
@T-One
T-One merged commit 8bddc6c into main Mar 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants