Commit f7dff99
authored
fix: invalidate series cache when book status changes (#409)
## Summary
Fixes a cache invalidation bug where changing a book's status on
`/books/:id` doesn't refresh the cache on the `/series/:name` page,
causing stale status badges and ratings to be displayed.
## Root Cause
The cache invalidation bug existed at two levels:
1. **Client-Side (React Query)**: `invalidateBookQueries()` in
`useBookStatus.ts` was not invalidating series queries
2. **Server-Side (Next.js)**: `SessionService` and `ProgressService`
were not calling `revalidatePath('/series')`
## Changes
**3 files modified, 3 lines added:**
- `hooks/useBookStatus.ts:57` - Added series query invalidation using
`queryKeys.series.all()`
- `lib/services/session.service.ts:1365` - Added
`revalidatePath('/series')`
- `lib/services/progress.service.ts:524` - Added
`revalidatePath('/series')`
## Implementation Details
The fix uses "nuclear" invalidation (invalidate all series queries) for
simplicity and reliability, consistent with the existing shelf
invalidation pattern when specific targeting is complex.
- `queryKeys.series.all()` returns `['series']`, which matches both
series list and all series detail pages
- `revalidatePath('/series')` revalidates both `/series` (list) and
`/series/:name` (detail) pages
## Testing
- ✅ All 4,013 tests pass (188 test files)
- ✅ No regressions detected
- ✅ Changes follow existing patterns
## Manual Testing
To verify the fix:
1. Open a series detail page (e.g., `/series/Harry%20Potter`)
2. Note a book's status badge
3. Change that book's status on `/books/:id`
4. Return to the series page - status should now update immediately1 parent 7b3cf28 commit f7dff99
3 files changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
| 524 | + | |
524 | 525 | | |
525 | 526 | | |
526 | 527 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1362 | 1362 | | |
1363 | 1363 | | |
1364 | 1364 | | |
| 1365 | + | |
1365 | 1366 | | |
1366 | 1367 | | |
1367 | 1368 | | |
| |||
0 commit comments