use turbo instead of my dog shit soft nav

This commit is contained in:
KingKDot
2026-07-13 19:30:03 -05:00
parent cfa95b3b16
commit e390dbc966
10 changed files with 290 additions and 398 deletions
+5 -38
View File
@@ -13,11 +13,10 @@ import { applyUserRoleUI, applyThumbnailWallVisibility } from "./nav/role-ui.js"
import { loadPluginNavItems } from "./nav/plugins-loader.js";
import { init as initCommandPalette } from "./command-palette.js";
import {
installPageResourceTracker,
runWithoutPageTracking,
setupSoftNavigation,
startPageTracking,
} from "./soft-nav.js";
setupTurboNavigation,
turboVisit,
} from "./turbo-navigation.js";
const host = document.getElementById("top-nav");
if (host) {
@@ -112,11 +111,7 @@ if (host) {
if (refs.accountSettingsBtn && !refs.accountSettingsBtn.dataset.boundSettings) {
refs.accountSettingsBtn.dataset.boundSettings = "true";
refs.accountSettingsBtn.addEventListener("click", () => {
if (window.overlordSoftNavigate) {
window.overlordSoftNavigate("/settings");
} else {
window.location.href = "/settings";
}
turboVisit("/settings");
});
}
@@ -160,32 +155,6 @@ if (host) {
}
});
const prefetchedPages = new Set();
const prefetchPage = (href) => {
try {
const url = new URL(href, window.location.href);
if (url.origin !== window.location.origin) return;
if (url.pathname === window.location.pathname && url.search === window.location.search) return;
const key = `${url.pathname}${url.search}`;
if (prefetchedPages.has(key)) return;
prefetchedPages.add(key);
const link = document.createElement("link");
link.rel = "prefetch";
link.as = "document";
link.href = key;
document.head.appendChild(link);
} catch {}
};
host.addEventListener("pointerenter", (event) => {
const link = event.target?.closest?.("a[href]");
if (link) prefetchPage(link.getAttribute("href"));
}, true);
host.addEventListener("focusin", (event) => {
const link = event.target?.closest?.("a[href]");
if (link) prefetchPage(link.getAttribute("href"));
});
async function loadCurrentUser() {
try {
const res = await fetch("/api/auth/me", { credentials: "include" });
@@ -243,14 +212,12 @@ if (host) {
});
});
installPageResourceTracker();
setupSoftNavigation(host, {
setupTurboNavigation({
onPathChange: (path) => {
applyActivePath(path);
applyBranding();
},
});
startPageTracking();
}
async function applyBranding() {