added channel/profile view

This commit is contained in:
2025-02-09 14:51:20 -05:00
parent 8939f52f20
commit f9d81ecb24
7 changed files with 573 additions and 95 deletions

View File

@@ -297,9 +297,14 @@ function handleQueryParams() {
*/
function handleHashChange() {
console.log("handleHashChange called, current hash =", window.location.hash);
const hash = window.location.hash || "";
const match = hash.match(/^#view=(.+)/);
// Use a regex that captures up to the first ampersand or end of string.
// E.g. "#view=channel-profile&npub=..." => viewName = "channel-profile"
const match = hash.match(/^#view=([^&]+)/);
if (!match || !match[1]) {
// No valid "#view=..." => default to "most-recent-videos"
import("./viewManager.js").then(({ loadView, viewInitRegistry }) => {
loadView("views/most-recent-videos.html").then(() => {
const initFn = viewInitRegistry["most-recent-videos"];
@@ -310,8 +315,11 @@ function handleHashChange() {
});
return;
}
const viewName = match[1];
const viewName = match[1]; // only the chunk before any '&'
const viewUrl = `views/${viewName}.html`;
// Now dynamically load that partial, then call its init function
import("./viewManager.js").then(({ loadView, viewInitRegistry }) => {
loadView(viewUrl).then(() => {
const initFn = viewInitRegistry[viewName];