A "Continue reading" shelf listing series the reader already finished (read to the last page, nothing new) is odd. Expose the last-read chapter's page_count on the read-progress list, and filter the shelf to drop entries that are caught up (on the last page of the latest chapter with no new chapters). Mid-chapter and has-new-chapters entries stay; the full history view is unaffected. Finished detection is a pure, unit-tested helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
21 lines
716 B
TypeScript
21 lines
716 B
TypeScript
import type { ReadProgressSummary } from '$lib/api/read_progress';
|
|
|
|
// Whether a read-progress entry has nothing left to continue: the reader is
|
|
// on the last page of the latest chapter and no newer chapters exist. Such
|
|
// finished series are kept off the homepage "Continue reading" shelf (the
|
|
// full history view still shows them).
|
|
export function isCaughtUp(
|
|
e: Pick<
|
|
ReadProgressSummary,
|
|
'new_chapters_count' | 'chapter_number' | 'chapter_page_count' | 'page'
|
|
>
|
|
): boolean {
|
|
return (
|
|
e.new_chapters_count === 0 &&
|
|
e.chapter_number != null &&
|
|
e.chapter_page_count != null &&
|
|
e.chapter_page_count > 0 &&
|
|
e.page >= e.chapter_page_count
|
|
);
|
|
}
|