Skip to content

fix: author pages keep loading past a page with no matching books - #465

Merged
kikootwo merged 2 commits into
mainfrom
fix/310-author-books-paging
Oct 27, 2026
Merged

kikootwo merged 2 commits into
mainfrom
fix/310-author-books-paging

Conversation

@kikootwo

@kikootwo kikootwo commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Closes #310

This fixes part 1 of the issue (author pages missing books). Part 2, about an indexer, is not covered here.

What changed

  • searchByAuthorAsin() (src/lib/integrations/audible.service.ts) works out hasMore from Audible's raw catalog page instead of the books left after the author-ASIN and language filters. More pages means the raw page had products, total_results > page * 50 (or a full raw page when Audible sends no total), and the page is below the new cap AUDIBLE_MAX_AUTHOR_PAGES (20).
  • Watched authors, entire catalog (scanAuthorBooks() in src/lib/services/watched-lists-releases.ts): a page with no matching books no longer ends the relevance scan. It reads on while Audible has more, up to its existing 4-page cap. The newest-first scan for new-releases-only watches already read past such pages and is unchanged.
  • Author page client (useAuthorBooks() in src/lib/hooks/useAuthors.ts): when the last page loaded has no books but more remain, the hook loads the next page by itself. While it does, the page shows loading instead of "No books found" (first page) or a Load more button that adds nothing (later pages).
  • Docs: documentation/integrations/audible.md (Gotchas line, Fixed Issues entry), documentation/features/watched-lists.md (author scan stop rule).

Why

The catalog API's author= param takes a name, so a page holds namesakes and books in other languages alongside the author's own. searchByAuthorAsin() set hasMore only when at least one book on the page passed the filters. For an author with a large catalog under a shared or common name (the issue's example is J.R.R. Tolkien), a page where nothing passed ended paging, though Audible had more pages holding more of the author's books. The author page then showed no Load more button, and entire-catalog watched authors never saw those books.

The client needed a change too: once the route reports a page with no books and more to come, the author page would show "No books found" for an empty first page, or a Load more button that added nothing for a later one.

Evidence

  • New tests/integrations/audible-author-paging.test.ts runs the real AudibleService (axios mocked, no Audible calls) on a 130-product catalog over three raw pages: page 1 has one of the author's books, page 2 has only namesakes and German editions, page 3 has two more. Through the real author-books route, page 2 returns no books with hasMore: true and page 3 returns both books. Through the real scanAuthorBooks(), the scan reads all three pages, finds all three books and reports the catalog complete. Further cases: no total_results with a full raw page, an empty raw page with a large total (stops), and the 20-page cap.
  • New tests/lib/hooks/useAuthors.test.tsx: the hook asks for the next page by itself after a page with no books, shows loading while skipping an empty first page, does not ask twice while a page is loading, waits for a click after a page with books, and stops on an empty last page or a failed fetch.
  • tests/services/watched-lists-releases.test.ts and tests/services/watched-lists-new-releases.test.ts: the old "stops at a page with no matching books" expectation now reads past that page (to page 3, or to the 4-page cap for the mixed-group cases).
  • With main's three source files (8ee4a84) and this branch's four test files: 11 failed, 25 passed, all on an assertion (hasMore false after a filtered-out page, the scan stops at page 2, the hook never asks for the next page). On this branch: 36/36 pass.

Checks

  • Unit tests for the changed code (vitest related on audible.service.ts, watched-lists-releases.ts and useAuthors.ts, plus the new test files): PASS, 86 files, 1188/1188
  • Type check and lint: PASS (tsc --noEmit clean; ESLint finds nothing new in the 7 touched files, the 13 no-explicit-any in audible.service.ts are on main too)
  • No image build or E2E run: the change is in src/lib only
  • Full unit suite: PR Tests (CI)

Risk and rollback

  • More Audible calls per author. The author page can now load pages it used to stop before, and loads past a page with no books without a click, so a big catalog under a common name costs more catalog requests. Each author page request is one catalog call as before.
  • The cap: AUDIBLE_MAX_AUTHOR_PAGES (20 pages, 1000 raw products) bounds the author page, so a wrong total_results cannot keep the client paging. An empty raw page also ends paging whatever the total says. An author whose catalog search returns more than 1000 raw products (usually a name shared with other authors) shows only books found in the first 1000.
  • Watched authors, entire catalog: up to 4 catalog pages per author per run as before, but an author that used to stop at an unmatched page now uses the rest of them (1 s between pages). Such scans can now find books they missed, so the next watched-list check may request books in those authors' catalogs that it skipped before.
  • Rollback: revert this PR. No data or schema changes.

Release note

  • Author pages and watched authors no longer stop early when a page of Audible results holds only other authors with the same name or books in other languages, so the rest of the author's books show up and are requested (Authors not showing all books #310).

🤖 Generated with Claude Code

kikootwo and others added 2 commits October 27, 2026 02:03
… matching books

searchByAuthorAsin now bases hasMore on Audible's raw page (total_results, or a
full page when there is no total), capped at AUDIBLE_MAX_AUTHOR_PAGES (20), so a
page of namesakes or other languages no longer ends paging. The entire-catalog
watched-author scan reads on to its 4-page cap instead of stopping at such a
page, and useAuthorBooks loads past a page with no books by itself, showing
loading rather than "No books found" while it does.

Fixes part 1 of #310.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kikootwo
kikootwo marked this pull request as ready for review October 27, 2026 06:21
@kikootwo
kikootwo merged commit ece1559 into main Oct 27, 2026
1 check passed
@kikootwo
kikootwo deleted the fix/310-author-books-paging branch October 27, 2026 06:25
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.

Authors not showing all books

1 participant