From ffadf7a0c6c2d4fc27ac7b7e4a2e8fcc1f81d7c4 Mon Sep 17 00:00:00 2001 From: Admin Date: Sun, 1 Mar 2026 20:09:06 +0500 Subject: [PATCH] fix: prevent book cards duplicating in continue-reading on repeated back-navigation HTMX was snapshotting the post-JS mutated home DOM into history; on back-navigation it restored the stale snapshot then re-ran the inline script, appending cards that were already present. Fix by: - hx-history="false" on the home root div so HTMX never caches the mutated DOM - clearing #continue-reading-grid before each script run as a defensive guard --- scraper/internal/server/ui.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scraper/internal/server/ui.go b/scraper/internal/server/ui.go index ddba39f..0980c92 100644 --- a/scraper/internal/server/ui.go +++ b/scraper/internal/server/ui.go @@ -119,7 +119,7 @@ func (s *Server) respond(w http.ResponseWriter, r *http.Request, title, fragment // ─── GET / — book catalogue ─────────────────────────────────────────────────── const homeTmpl = ` -
+

libnovel

Browse Rankings @@ -205,6 +205,10 @@ const homeTmpl = ` var continueGrid = document.getElementById('continue-reading-grid'); var availableHeading = document.getElementById('available-heading'); + // Clear any stale cards from a previous render (e.g. HTMX re-executing this + // script after a history restore) before re-populating. + if (continueGrid) continueGrid.innerHTML = ''; + if (inProgress.length > 0) { var moved = 0; inProgress.forEach(function(slug) {