feat(recents): Hide action on recents rows — list-only, never touches the book on disk; 'Hidden (n)' disclosure to unhide; re-opening a book un-hides it; hidden entries dropped from Open Recent menu

This commit is contained in:
avi 2026-10-02 14:30:04 -05:00
commit 3e6962eda9
9 changed files with 264 additions and 79 deletions

View file

@ -20,6 +20,8 @@ const {
hasBook,
listRecents,
addRecent,
hideRecent,
unhideRecent,
makeChapterId,
chapterFileName,
} = mod;
@ -65,6 +67,19 @@ ok(r2.length === 2 && r2[0].path === "/other", "second recent added to top");
const r3 = addRecent(rf, { path: dir, title: "My Novel", lastOpened: "2026-03-03T00:00:00Z" });
ok(r3.length === 2 && r3[0].path === dir, "duplicate path deduped + moved to top");
// Hide/unhide: list-only — entry stays in the file, disk untouched.
const h1 = hideRecent(rf, "/other");
ok(h1.find((r) => r.path === "/other")?.hidden === true, "hide marks entry hidden");
ok(h1.length === 2, "hide keeps the entry in the file");
ok(fs.existsSync(path.join(dir, "folio.json")), "hide leaves book on disk intact");
const h2 = addRecent(rf, { path: "/other", title: "Other", lastOpened: "2026-04-04T00:00:00Z" });
ok(h2.find((r) => r.path === "/other")?.hidden === false, "re-opening un-hides");
const h3 = hideRecent(rf, "/other");
const h4 = unhideRecent(rf, "/other");
ok(h4.find((r) => r.path === "/other")?.hidden === false, "unhide clears the flag");
ok(h3.length === 2 && h4.length === 2, "hide/unhide never drop entries");
ok(hideRecent(rf, "/nowhere").length === 2, "hide of unknown path is a no-op");
const id = makeChapterId("Chapter One");
ok(id.startsWith("chapter-one-"), "chapter id slugified: " + id);
ok(chapterFileName(id) === `${id}.md`, "filename is <id>.md");