fix: reader loads the full chapter list for prev/next and the dropdown

The reader fetched only the first 200 chapters, so a deep chapter (#250) fell
outside the window and its prev/next chevrons resolved to null — a dead end —
and the chapter dropdown was truncated. Add listAllChapters, which pages
through the API's 200-row cap, and use it in the reader loader.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-11 15:02:44 +02:00
parent 69a9309c54
commit c308eb3eac
4 changed files with 55 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
import { getManga } from '$lib/api/mangas';
import { getChapter, getChapterPages, listChapters } from '$lib/api/chapters';
import { getChapter, getChapterPages, listAllChapters } from '$lib/api/chapters';
import { getMyReadProgressForManga } from '$lib/api/read_progress';
import type { PageLoad } from './$types';
@@ -13,19 +13,18 @@ export const load: PageLoad = async ({ params, url }) => {
// `null` for guests or first-time openers — the reader uses
// this to seed its session-local high-water mark.
getMyReadProgressForManga(params.id),
// Loaded so the reader can compute prev/next chapter for the
// chevron-driven chapter navigation. limit=200 covers every
// realistic series; mangas with more chapters will lose some
// chapter-jump precision at the tail edge but the in-page
// navigation still works fine.
listChapters(params.id, { limit: 200 })
// The FULL chapter list (paged through the API's 200-row cap) so the
// prev/next chevrons and the chapter dropdown work even for a deep
// chapter — a single 200-row window dead-ended chapter #250 with null
// neighbours.
listAllChapters(params.id)
]);
return {
manga,
chapter,
pages,
readProgress,
chapters: chapterList.items,
chapters: chapterList,
// `?page=N` lets the prev-chapter chevron land directly on the
// last page of the chapter it just navigated to. `last` is a
// convenience sentinel for "however many pages this chapter