From 4d186f76dc120b67a3e7458c37ca71772c6e3eec Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 12 Mar 2026 17:21:34 -0400 Subject: [PATCH] refactor(collections): remove dead Alpine.js exports and DOMContentLoaded listeners - Remove DOMContentLoaded listeners for setupHTMXAuth, initColorSelection, and setupHTMXModalInit - Delete dead Alpine.data exports: addbooksToAdd, removebooksToAdd, toggleBookForRemoval, toggleBookSelection, initCollectionDetail, initIconSelection, initColorSelection - Add missing setupHTMXAuth to export statement (it was called but not exported) - Remove 14 lines of auto-initialization code that's no longer needed This fixes "X is not defined" console errors for functions that were deleted in commit 93710a1 but were still in Alpine.data export. The collections.templ template was also updated to remove calls to these deleted functions. These changes align with the SSR architecture where most collection functionality is server-rendered and client-side JavaScript is used sparingly. --- web/src/collections.ts | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/web/src/collections.ts b/web/src/collections.ts index 68ea040..b5f177a 100644 --- a/web/src/collections.ts +++ b/web/src/collections.ts @@ -199,12 +199,6 @@ function setupHTMXAuth(): void { (evt as any).detail.headers["Authorization"] = `Bearer ${token}`; }); } -// Auto-initialize HTMX auth when DOM is ready -if (document.readyState === "loading") { - document.addEventListener("DOMContentLoaded", setupHTMXAuth); -} else { - setupHTMXAuth(); -} function navigateToCollection(element: HTMLElement): void { // Check if the click target is a button @@ -288,13 +282,6 @@ function initColorSelection(): void { }); } -// Auto-initialize when DOM is ready -if (document.readyState === "loading") { - document.addEventListener("DOMContentLoaded", initColorSelection); -} else { - initColorSelection(); -} - // Initialize icon grid when modal is loaded via HTMX function setupHTMXModalInit(): void { document.body.addEventListener("htmx:afterSwap", function (evt: Event) { @@ -304,12 +291,6 @@ function setupHTMXModalInit(): void { } }); } -// Auto-initialize when DOM is ready -if (document.readyState === "loading") { - document.addEventListener("DOMContentLoaded", setupHTMXModalInit); -} else { - setupHTMXModalInit(); -} // Icon data with keywords (single source of truth) const iconData: Record = { @@ -446,6 +427,7 @@ export { selectIcon, showAddBooksModal, showAllIcons, + setupHTMXAuth, testRule, toggleBookForRemoval, toggleBookSelection,