Repository navigation
fix: author pages keep loading past a page with no matching books - #465
Merged
Merged
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 outhasMorefrom 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 capAUDIBLE_MAX_AUTHOR_PAGES(20).scanAuthorBooks()insrc/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.useAuthorBooks()insrc/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).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()sethasMoreonly 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
tests/integrations/audible-author-paging.test.tsruns the realAudibleService(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 withhasMore: trueand page 3 returns both books. Through the realscanAuthorBooks(), the scan reads all three pages, finds all three books and reports the catalog complete. Further cases: nototal_resultswith a full raw page, an empty raw page with a large total (stops), and the 20-page cap.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.tsandtests/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).main's three source files (8ee4a84) and this branch's four test files: 11 failed, 25 passed, all on an assertion (hasMorefalse 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
vitest relatedonaudible.service.ts,watched-lists-releases.tsanduseAuthors.ts, plus the new test files): PASS, 86 files, 1188/1188tsc --noEmitclean; ESLint finds nothing new in the 7 touched files, the 13no-explicit-anyinaudible.service.tsare onmaintoo)src/libonlyRisk and rollback
AUDIBLE_MAX_AUTHOR_PAGES(20 pages, 1000 raw products) bounds the author page, so a wrongtotal_resultscannot 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.Release note
🤖 Generated with Claude Code