mirror of
https://github.com/smittix/intercept.git
synced 2026-06-08 14:11:54 -07:00
fix: prevent full page reload when clicking Main Dashboard button
Intercept .nav-dashboard-btn clicks to perform SPA-style navigation instead of a full page reload. After switchMode() updates the URL to /?mode=<x> via pushState, clicking href="/" previously caused a round- trip reload. Now the click handler stops active scans, destroys the current mode, shows the welcome overlay, and pushes '/' onto history. Also update popstate to restore the welcome page when navigating back to '/' with no mode param. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4609,6 +4609,31 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (!window._dashboardHomeBtnBound) {
|
||||
window._dashboardHomeBtnBound = true;
|
||||
document.addEventListener('click', (event) => {
|
||||
if (event.defaultPrevented || event.button !== 0) return;
|
||||
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
||||
const link = event.target && event.target.closest
|
||||
? event.target.closest('.nav-dashboard-btn')
|
||||
: null;
|
||||
if (!link) return;
|
||||
try {
|
||||
const href = new URL(link.href, window.location.href);
|
||||
if (href.origin !== window.location.origin || href.pathname !== '/') return;
|
||||
} catch (_) { return; }
|
||||
event.preventDefault();
|
||||
stopActiveLocalScansForNavigation();
|
||||
destroyCurrentMode();
|
||||
const welcome = document.getElementById('welcomePage');
|
||||
if (welcome) {
|
||||
welcome.classList.remove('fade-out');
|
||||
welcome.style.display = '';
|
||||
}
|
||||
window.history.pushState({}, '', '/');
|
||||
});
|
||||
}
|
||||
|
||||
function postStopRequest(url, timeoutMs = LOCAL_STOP_TIMEOUT_MS) {
|
||||
const controller = (typeof AbortController !== 'undefined') ? new AbortController() : null;
|
||||
const timeoutId = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
||||
@@ -5157,6 +5182,13 @@
|
||||
const mode = getModeFromQuery();
|
||||
if (mode && mode !== currentMode) {
|
||||
switchMode(mode, { updateUrl: false });
|
||||
} else if (!mode) {
|
||||
destroyCurrentMode();
|
||||
const welcome = document.getElementById('welcomePage');
|
||||
if (welcome) {
|
||||
welcome.classList.remove('fade-out');
|
||||
welcome.style.display = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user