From 46d1170a5296b9eaf9e83d37f907081db6065b10 Mon Sep 17 00:00:00 2001 From: Keep Creating Online <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 6 Feb 2025 16:11:16 -0500 Subject: [PATCH] fixed bug in hash view URL calling --- js/app.js | 15 +++++++++++++-- js/index.js | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index c745da7..e40a32f 100644 --- a/js/app.js +++ b/js/app.js @@ -207,8 +207,19 @@ class bitvidApp { this.setupEventListeners(); disclaimerModal.show(); - // 6. Load the default view (most-recent-videos.html) - await loadView("views/most-recent-videos.html"); + // 6) Load the default view ONLY if there's no #view= already + if (!window.location.hash || !window.location.hash.startsWith("#view=")) { + console.log( + "[app.init()] No #view= in the URL, loading default home view" + ); + await loadView("views/most-recent-videos.html"); + } else { + console.log( + "[app.init()] Found hash:", + window.location.hash, + "so skipping default load" + ); + } // 7. Once loaded, get a reference to #videoList this.videoList = document.getElementById("videoList"); diff --git a/js/index.js b/js/index.js index 78586c9..732f1c1 100644 --- a/js/index.js +++ b/js/index.js @@ -305,6 +305,7 @@ function handleQueryParams() { * Handle #view=... in the hash and load the correct partial view. */ function handleHashChange() { + console.log("handleHashChange called, current hash =", window.location.hash); const hash = window.location.hash || ""; // Expecting something like #view=most-recent-videos const match = hash.match(/^#view=(.+)/);