bugfix: /bookmarks renders manga title and cover

The bookmarks list was rendering "Manga bookmark <date>" with no
indication of which manga the bookmark referred to. The data is
already in the DB — the list query just wasn't pulling it.

Backend:
- BookmarkSummary gains manga_title (String) and
  manga_cover_image_path (Option<String>). Populated by an INNER JOIN
  on `mangas` in `repo::bookmark::list_for_user`. The JOIN is INNER
  because `bookmarks.manga_id` has ON DELETE CASCADE, so a bookmark
  cannot outlive its manga. Chapter LEFT JOIN unchanged.
- The existing list_me_enriches_chapter_bookmarks_with_chapter_number
  test now also asserts manga_title is populated for both chapter-
  and manga-level bookmarks, and that manga_cover_image_path is null
  when no cover was uploaded.

Frontend:
- Bookmark type carries optional manga_title and
  manga_cover_image_path (optional because POST /bookmarks returns
  the bare Bookmark, not the enriched summary).
- /bookmarks page redesigned as a grid: cover thumbnail (64×96 with
  a placeholder when no cover) on the left, then the manga title (as
  the primary link), then either "Chapter N — page M" linked to the
  reader, "(chapter removed)" for orphan chapter bookmarks, or
  "Whole manga" for manga-level bookmarks. Bookmark date moves to a
  subdued footer.
- E2E fixtures track the enriched shape returned by the list endpoint
  (vs. the bare Bookmark returned by POST). The toggle test now
  asserts the manga title appears on the bookmarks card after the
  bookmark is created.

Also: tighten .gitignore. `/data` only catches the compose volume
root; the dev backend writes to `/backend/data` (default STORAGE_DIR
is `./data/storage` relative to backend cwd), so local uploads were
showing as untracked. Adding `/backend/data` keeps test uploads out
of the index.

Lockstep version bump to 0.11.1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-05-17 10:46:01 +02:00
parent 08e4f4fa18
commit dee7f1d160
9 changed files with 139 additions and 29 deletions

View File

@@ -13,16 +13,23 @@ pub struct Bookmark {
pub created_at: DateTime<Utc>,
}
/// `Bookmark` enriched with the chapter's reader-facing number, so the
/// frontend can build `/manga/{id}/chapter/{number}` links without an
/// extra round-trip per bookmark. Populated by a LEFT JOIN; `null` for
/// manga-level bookmarks or for chapter bookmarks whose chapter has
/// since been deleted (`chapter_id` is `ON DELETE SET NULL`).
/// `Bookmark` enriched with the parent manga's title + cover and the
/// chapter's reader-facing number, so the /bookmarks page can render a
/// proper card (title, cover, link target) without N+1 round-trips.
/// Populated by JOINs in `repo::bookmark::list_for_user`:
/// - `manga_title` / `manga_cover_image_path` come from `mangas` via an
/// INNER JOIN (safe: `bookmarks.manga_id` is `ON DELETE CASCADE`, so a
/// bookmark cannot outlive its manga).
/// - `chapter_number` comes from `chapters` via a LEFT JOIN; `null` for
/// manga-level bookmarks or for chapter bookmarks whose chapter has
/// since been deleted (`bookmarks.chapter_id` is `ON DELETE SET NULL`).
#[derive(Debug, Clone, Serialize, FromRow)]
pub struct BookmarkSummary {
pub id: Uuid,
pub user_id: Uuid,
pub manga_id: Uuid,
pub manga_title: String,
pub manga_cover_image_path: Option<String>,
pub chapter_id: Option<Uuid>,
pub chapter_number: Option<i32>,
pub page: Option<i32>,

View File

@@ -53,11 +53,14 @@ pub async fn list_for_user(
b.id,
b.user_id,
b.manga_id,
m.title AS manga_title,
m.cover_image_path AS manga_cover_image_path,
b.chapter_id,
c.number AS chapter_number,
b.page,
b.created_at
FROM bookmarks b
INNER JOIN mangas m ON m.id = b.manga_id
LEFT JOIN chapters c ON c.id = b.chapter_id
WHERE b.user_id = $1
ORDER BY b.created_at DESC