Skip exchange PnL sync on hub iframe soft nav to fix slow records tab.
Remove hover prefetch and mark soft-nav fetches so Gate/OKX render pages from local DB without blocking on exchange history sync. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+11
-47
@@ -408,8 +408,6 @@
|
||||
if (!isHubLinked()) return;
|
||||
|
||||
let navToken = 0;
|
||||
const prefetch = new Map();
|
||||
const PREFETCH_MAX = 8;
|
||||
|
||||
function isSoftNavLink(a) {
|
||||
if (!a || !a.getAttribute) return false;
|
||||
@@ -417,25 +415,11 @@
|
||||
return !!a.closest(".top-nav, .strategy-subnav");
|
||||
}
|
||||
|
||||
function rememberPrefetch(href, html) {
|
||||
if (!href || !html) return;
|
||||
if (prefetch.has(href)) prefetch.delete(href);
|
||||
prefetch.set(href, html);
|
||||
while (prefetch.size > PREFETCH_MAX) {
|
||||
const first = prefetch.keys().next().value;
|
||||
prefetch.delete(first);
|
||||
}
|
||||
}
|
||||
|
||||
function warmPrefetch(href) {
|
||||
if (!href || prefetch.has(href)) return;
|
||||
const token = navToken;
|
||||
fetch(href, { credentials: "same-origin" })
|
||||
.then((r) => (r.ok ? r.text() : null))
|
||||
.then((html) => {
|
||||
if (html && token === navToken) rememberPrefetch(href, html);
|
||||
})
|
||||
.catch(() => {});
|
||||
function softNavFetch(href) {
|
||||
return fetch(href, {
|
||||
credentials: "same-origin",
|
||||
headers: { "X-Instance-Soft-Nav": "1" },
|
||||
});
|
||||
}
|
||||
|
||||
async function navigateInFrame(href, opts) {
|
||||
@@ -443,17 +427,13 @@
|
||||
notifyParentFrameNavStart();
|
||||
ensureNavOverlay();
|
||||
try {
|
||||
let html = prefetch.get(href);
|
||||
if (html) prefetch.delete(href);
|
||||
if (!html) {
|
||||
const r = await fetch(href, { credentials: "same-origin" });
|
||||
if (token !== navToken) return;
|
||||
if (!r.ok) {
|
||||
location.assign(href);
|
||||
return;
|
||||
}
|
||||
html = await r.text();
|
||||
const r = await softNavFetch(href);
|
||||
if (token !== navToken) return;
|
||||
if (!r.ok) {
|
||||
location.assign(href);
|
||||
return;
|
||||
}
|
||||
let html = await r.text();
|
||||
if (token !== navToken) return;
|
||||
html = injectNavOverlayIntoHtml(html, get());
|
||||
let path = href;
|
||||
@@ -494,22 +474,6 @@
|
||||
true
|
||||
);
|
||||
|
||||
document.addEventListener(
|
||||
"pointerenter",
|
||||
(ev) => {
|
||||
const a = ev.target.closest("a[href]");
|
||||
if (!a || !isSoftNavLink(a)) return;
|
||||
const rawHref = a.getAttribute("href");
|
||||
if (!rawHref || rawHref.startsWith("#") || rawHref.startsWith("javascript:")) return;
|
||||
try {
|
||||
const target = new URL(rawHref, location.href);
|
||||
if (target.origin !== location.origin) return;
|
||||
warmPrefetch(target.pathname + target.search + target.hash);
|
||||
} catch (_) {}
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
window.addEventListener("popstate", () => {
|
||||
void navigateInFrame(location.pathname + location.search + location.hash, { replace: true });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user