From 49723189b0626fcdabc67c8846b8e47c72fa7322 Mon Sep 17 00:00:00 2001 From: jesusjimenezc Date: Mon, 16 Nov 2026 19:35:36 -0600 Subject: [PATCH] fix: show the catalog title of locked books on the shelf The Kindle catalog already gives the title of a book before it is unlocked, but the shelf and the side panel still showed its ASIN. A locked book now shows its title when it is known, with the ASIN in the detail line; one with no title keeps the ASIN and "title once unlocked". The web demo does the same, and the README and PRODUCT.md say so. --- PRODUCT.md | 4 ++-- README.es.md | 4 ++-- README.md | 4 ++-- crates/anzu/src/demo.rs | 7 ++++--- crates/anzu/src/ui/demo.rs | 12 ++++++------ crates/anzu/src/ui/library.rs | 20 +++++++++++++------- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/PRODUCT.md b/PRODUCT.md index 1455335..a24eee2 100644 --- a/PRODUCT.md +++ b/PRODUCT.md @@ -44,8 +44,8 @@ why and does nothing. The KFX to EPUB converter is its own code. HTML and no browser: the `web` value under Platform only means that it does not follow the iOS or Android guidelines. - Book states: with DRM, unlocked, converted. -- The real title is only known once the book is unlocked; until then its ASIN is - shown. +- A book's title comes from the Kindle app's catalog, or from the book once unlocked; + a locked book with no title in the catalog shows its ASIN. - Converts text books. Comics, fixed layout and dictionaries are out of scope. - The interface is in English by default and also available in Spanish. - Light and dark theme: it follows the system or the user sets it. diff --git a/README.es.md b/README.es.md index d22405c..6249276 100644 --- a/README.es.md +++ b/README.es.md @@ -101,8 +101,8 @@ cualquier otro programa. 1. **Descarga tus libros** en la app de Kindle, como siempre. 2. **Abre Anzu.** Encuentra la app de Kindle y pone tus libros en estantes según lo que - les falta: por desbloquear, listos para EPUB o ya en EPUB. Hasta que un libro se - desbloquea ves un código en lugar del título; el título real aparece al desbloquearlo. + les falta: por desbloquear, listos para EPUB o ya en EPUB. Cada libro muestra el + título que tiene en la app de Kindle; si allí no lo tiene, ves su código hasta desbloquearlo. 3. **Marca los libros que quieras.** El panel lateral los lista con lo que se hará con cada uno. Elige la carpeta donde irán los EPUB (`Documents\EPUB` por defecto). diff --git a/README.md b/README.md index 94fc73f..6b723d2 100644 --- a/README.md +++ b/README.md @@ -99,8 +99,8 @@ say so. To remove it, uninstall Anzu from Settings › Apps like any other progr 1. **Download your books** in the Kindle app, as you normally do. 2. **Open Anzu.** It finds the Kindle app and puts your books on shelves by what they still - need: to unlock, ready for EPUB, or already in EPUB. Until a book is unlocked - you see a code instead of its title; the real title appears once it is unlocked. + need: to unlock, ready for EPUB, or already in EPUB. Each book shows the title + the Kindle app has for it; one without a title there shows its code until it is unlocked. 3. **Tick the books you want.** The side panel lists them with what will be done to each. Choose the folder where the EPUB files will go (`Documents\EPUB` by default). diff --git a/crates/anzu/src/demo.rs b/crates/anzu/src/demo.rs index b277862..f7be2bc 100644 --- a/crates/anzu/src/demo.rs +++ b/crates/anzu/src/demo.rs @@ -100,8 +100,9 @@ impl DemoSystem { .filter(|b| b.downloaded) .map(|b| Book { asin: b.asin.to_string(), - // The real title is only known once the book is unlocked. - title: (b.state != BookState::Locked).then(|| b.title.to_string()), + // As in the app, which reads it from the Kindle app's catalog: the title is + // known before the book is unlocked. + title: Some(b.title.to_string()), source: Path::new(CONTENT_DIR).join(format!("{}_EBOK", b.asin)).join(format!("{}_EBOK.azw", b.asin)), size: b.size, state: b.state, @@ -229,7 +230,7 @@ mod tests { system.download_all(); let books = system.scan(); assert_eq!(books.len(), 3); - assert!(books.iter().filter(|b| b.state == BookState::Locked).all(|b| b.title.is_none())); + assert!(books.iter().all(|b| b.title.is_some())); } #[test] diff --git a/crates/anzu/src/ui/demo.rs b/crates/anzu/src/ui/demo.rs index b0c4ef2..8339b6d 100644 --- a/crates/anzu/src/ui/demo.rs +++ b/crates/anzu/src/ui/demo.rs @@ -445,7 +445,7 @@ mod tests { /// As in the app, a book's real title appears only once the run has finished and the /// window reads the library again, never ahead of what has been shown. #[test] - fn titles_appear_when_the_run_is_shown_finished() { + fn books_show_their_titles_before_and_after_the_run() { use eframe::App; let ctx = egui::Context::default(); super::super::theme::install(&ctx); @@ -461,12 +461,12 @@ mod tests { app.ui(ui, &mut frame); }); output.textures_delta.clear(); - let titled = app.books.iter().filter(|b| b.title.is_some()).count(); - if app.run.result.is_none() { - assert_eq!(titled, 1, "only Walden has a title before the run ends (frame {n})"); - } else { + // As in the app, which reads titles from the Kindle catalog: every book shows its + // title, locked or not. + assert!(app.books.iter().all(|b| b.title.is_some()), "a book without its title (frame {n})"); + if app.run.result.is_some() { seen_finished = true; - assert_eq!(titled, 3); + assert_eq!(app.books.len(), 3); } } assert!(seen_finished); diff --git a/crates/anzu/src/ui/library.rs b/crates/anzu/src/ui/library.rs index 136f496..2d3ece3 100644 --- a/crates/anzu/src/ui/library.rs +++ b/crates/anzu/src/ui/library.rs @@ -28,6 +28,9 @@ const SHELVES: [BookState; 3] = [BookState::Locked, BookState::Unlocked, BookSta struct Row { asin: String, title: String, + /// Whether the title is the book's own, from the Kindle catalog or the unlocked book, + /// rather than a fallback made from the ASIN. + named: bool, size: u64, state: BookState, } @@ -315,7 +318,7 @@ fn shelves(app: &mut AnzuApp, ui: &mut egui::Ui, p: theme::Palette, t: &Strings) .books .iter() .filter(|b| b.state == state) - .map(|b| Row { asin: b.asin.clone(), title: AnzuApp::display_title(b, t), size: b.size, state: b.state }) + .map(|b| Row { asin: b.asin.clone(), title: AnzuApp::display_title(b, t), named: b.title.is_some(), size: b.size, state: b.state }) .collect(); if rows.is_empty() { continue; @@ -451,11 +454,14 @@ fn card(app: &mut AnzuApp, ui: &mut egui::Ui, p: theme::Palette, t: &Strings, ro let text_left = cover.right() + 12.0; let text_width = check.left() - 10.0 - text_left; let title_color = dim(if row.state == BookState::Locked { p.muted } else { p.fg }); - let title = if row.state == BookState::Locked { row.asin.clone() } else { row.title.clone() }; + // A locked book whose title is not known yet shows its ASIN until it is unlocked. + let unnamed = row.state == BookState::Locked && !row.named; + let title = if unnamed { row.asin.clone() } else { row.title.clone() }; let title = elided(&painter, &title, theme::bold_font(14.0), title_color, text_width); - let detail = match row.state { - BookState::Locked => format!("{} · {}", t.human_size(row.size), t.title_after_unlock), - _ => format!("{} · {}", row.asin, t.human_size(row.size)), + let detail = if unnamed { + format!("{} · {}", t.human_size(row.size), t.title_after_unlock) + } else { + format!("{} · {}", row.asin, t.human_size(row.size)) }; let detail = elided(&painter, &detail, theme::regular_font(12.0), dim(p.muted), text_width); let top = rect.center().y - (title.size().y + 3.0 + detail.size().y) / 2.0; @@ -567,7 +573,7 @@ fn chosen_list(app: &AnzuApp, ui: &mut egui::Ui, p: theme::Palette, t: &Strings) painter.rect_filled(dot, 3, icons::state_fill(book.state)); let what = painter.layout_no_wrap(what.to_string(), theme::regular_font(12.0), p.muted); let what_left = rect.right() - what.size().x; - let name = if book.state == BookState::Locked { book.asin.clone() } else { AnzuApp::display_title(book, t) }; + let name = if book.state == BookState::Locked && book.title.is_none() { book.asin.clone() } else { AnzuApp::display_title(book, t) }; let name = elided(painter, &name, theme::regular_font(13.0), p.fg, what_left - 10.0 - (rect.left() + 18.0)); painter.galley(Pos2::new(rect.left() + 18.0, rect.center().y - name.size().y / 2.0), name, p.fg); painter.galley(Pos2::new(what_left, rect.center().y - what.size().y / 2.0), what, p.muted); @@ -633,7 +639,7 @@ mod tests { use super::*; fn row(asin: &str, title: &str, size: u64, state: BookState) -> Row { - Row { asin: asin.into(), title: title.into(), size, state } + Row { asin: asin.into(), title: title.into(), named: true, size, state } } fn sample() -> Vec {