fix(home): keep finished series off the Continue-reading shelf

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>
This commit is contained in:
MechaCat02
2026-07-04 21:52:58 +02:00
parent 3824eaafb2
commit bfaa166e0a
14 changed files with 133 additions and 6 deletions

View File

@@ -191,6 +191,32 @@ async fn list_reports_new_chapters_since_last_read(pool: PgPool) {
assert_eq!(body["items"][0]["new_chapters_count"], 2);
}
#[sqlx::test(migrations = "./migrations")]
async fn list_reports_last_read_chapter_page_count(pool: PgPool) {
let h = common::harness(pool);
let (_, cookie) = common::register_user(&h.app).await;
let manga_id = common::seed_manga_via_api(&h.app, &cookie, "Berserk").await;
// seed_chapter uploads a single page, so page_count is 1.
let ch1 = seed_chapter(&h.app, &cookie, manga_id, 1).await;
let _ = upsert_progress(
&h.app,
&cookie,
json!({ "manga_id": manga_id.to_string(), "chapter_id": ch1, "page": 1 }),
)
.await;
let resp = h
.app
.clone()
.oneshot(common::get_with_cookie("/api/v1/me/read-progress", &cookie))
.await
.unwrap();
let body = common::body_json(resp).await;
// Exposes the last-read chapter's page count so a client can tell a
// finished series (on the last page) from one still in progress.
assert_eq!(body["items"][0]["chapter_page_count"], 1);
}
#[sqlx::test(migrations = "./migrations")]
async fn list_new_chapters_count_is_zero_at_latest_chapter(pool: PgPool) {
let h = common::harness(pool);