fix(podcasts): code-review pass over the session's UI surfaces

Findings from the systematic gotcha-class review before the browser
pass:

- The collection smart editor's Apply derived the collection NAME from
  document.title — which parses to "Smart Collection", RENAMING the
  collection on every apply. The server now renders the real name
  (data-collection-name) and the write path refuses to proceed without
  it.
- TestRenderingPartialsRender pinned the pre-episode-collections
  empty-state copy ("No books in this collection yet.") — updated to
  the shipped label ("Nothing in this collection yet."; collections
  hold episodes now).
- The deleted handler-local rule comparators (evaluateRule/
  compareValues — removed in item 3.4's single-evaluator refactor)
  left behind two unit-test files testing the duplicates; deleted.
  Their semantics remain covered at the service level
  (TestEvaluateRules_* over FieldMatches/EvaluateRules) and
  TestTextToString (which actually pins utils.PgTextString) stays.

Everything else reviewed clean against the gotcha classes: templ
whole-expression attrs, ?={ boolean attrs, JSONArg quoting in
x-init/data attrs, Alpine CSP store paths, htmx form-encoding, the
" assert escaping, and the aria-label selector contract on the
player's reload listener.
This commit is contained in:
John O'Keefe committed 2026-10-30 19:38:39 -04:00
1 parent 94bd69d22d
commit c54430c254
6 files changed
+75 -552

No files matched your search

+9 -2
View File
@@ -24,11 +24,16 @@ function initCollectionRules(id: string, _scope: string, _treeJSON: string): voi
showToast("Not authenticated", "error");
return;
}
const name = pageCollectionName();
if (!name) {
showToast("Cannot determine the collection name", "error");
return;
}
try {
const response = await fetch(`/api/collections/${collectionId}`, {
method: "PUT",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
body: JSON.stringify({ name: pageCollectionName(), filter_tree: JSON.parse(wire) }),
body: JSON.stringify({ name, filter_tree: JSON.parse(wire) }),
});
if (response.ok) {
showToast("Smart collection updated", "success");
@@ -45,7 +50,9 @@ function initCollectionRules(id: string, _scope: string, _treeJSON: string): voi
}
function pageCollectionName(): string {
return document.title.split(" - ")[0] || "Collection";
// The server renders the real name (the page title is presentation,
// and parsing it would RENAME the collection to "Smart Collection").
return document.body.dataset.collectionName || "";
}
function backToCollection(): void {