fix: refresh sidebar counts after photo mutations

LIBRARY_STATS_QUERY_KEY was never invalidated by the bulk/single
mutation paths in RightSidebar and PhotoInfoPanel, so the All Photos
/ Rated / Discarded / Tags badges only updated on reload. Add it to
both shared invalidation helpers and the inline updateMutation, and
correct the stale docstring on useLibraryStatsQuery.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 20:35:17 +02:00
parent 30cbcb8cd1
commit 870e7dd3d3
3 changed files with 8 additions and 2 deletions

View File

@@ -6,8 +6,9 @@ export const LIBRARY_STATS_QUERY_KEY = ['library', 'stats'] as const
/**
* Per-section counts for the LeftSidebar badges (All Photos, Rated,
* Duplicates, Discarded). Cached briefly so navigating around doesn't
* re-fetch on every click; invalidated on photo mutations through the
* standard ['photos'] invalidation in the mutation onSuccess paths.
* re-fetch on every click. Mutations that change a photo's rating,
* discard flag, tags, etc. must invalidate LIBRARY_STATS_QUERY_KEY in
* their onSuccess so the badges stay live.
*/
export function useLibraryStatsQuery() {
return useQuery<LibraryStats>({