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:
2
backend/Cargo.lock
generated
2
backend/Cargo.lock
generated
@@ -1558,7 +1558,7 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
|
||||
|
||||
[[package]]
|
||||
name = "mangalord"
|
||||
version = "0.103.0"
|
||||
version = "0.104.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"argon2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mangalord"
|
||||
version = "0.103.0"
|
||||
version = "0.104.0"
|
||||
edition = "2021"
|
||||
default-run = "mangalord"
|
||||
|
||||
|
||||
@@ -24,6 +24,11 @@ pub struct ReadProgressSummary {
|
||||
/// `None` when the chapter was deleted after this row was written
|
||||
/// (FK ON DELETE SET NULL on `chapter_id`).
|
||||
pub chapter_number: Option<i32>,
|
||||
/// Page count of the last-read chapter (`None` when unknown / deleted).
|
||||
/// Lets a client distinguish a finished series (read to the last page,
|
||||
/// nothing new) from one still in progress — e.g. to keep finished
|
||||
/// series off a "Continue reading" shelf.
|
||||
pub chapter_page_count: Option<i32>,
|
||||
pub page: i32,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
/// How many chapters sit past the reader's last-read chapter (by
|
||||
|
||||
@@ -141,6 +141,7 @@ pub async fn list_for_user(
|
||||
m.cover_image_path AS manga_cover_image_path,
|
||||
rp.chapter_id,
|
||||
c.number AS chapter_number,
|
||||
c.page_count AS chapter_page_count,
|
||||
rp.page,
|
||||
rp.updated_at,
|
||||
-- Personal "new since last read": how many distinct chapter
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user