perf: embed shell soft nav, tab cache, and lighter options page boot
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,10 +4,12 @@
|
||||
const root = document.getElementById("options-root");
|
||||
if (!root) return;
|
||||
|
||||
const panelCache = (window.__optionsPanelCache = window.__optionsPanelCache || {});
|
||||
|
||||
const state = {
|
||||
underlying: root.dataset.defaultUnderly || "ETH",
|
||||
optType: "C",
|
||||
chain: null,
|
||||
chain: panelCache.chain || null,
|
||||
selectedInst: null,
|
||||
};
|
||||
|
||||
@@ -254,6 +256,9 @@
|
||||
return;
|
||||
}
|
||||
state.chain = d;
|
||||
panelCache.chain = d;
|
||||
panelCache.underlying = state.underlying;
|
||||
panelCache.optType = state.optType;
|
||||
state.selectedInst = null;
|
||||
parkOrderPanel();
|
||||
renderExpiries();
|
||||
@@ -457,6 +462,28 @@
|
||||
refreshHistory();
|
||||
}
|
||||
|
||||
function bootOptionsPanel() {
|
||||
updateSizeInputs();
|
||||
const hasCache =
|
||||
panelCache.chain &&
|
||||
panelCache.underlying === state.underlying &&
|
||||
panelCache.optType === state.optType;
|
||||
if (hasCache) {
|
||||
state.chain = panelCache.chain;
|
||||
renderExpiries();
|
||||
renderStrikes();
|
||||
refreshAllPositions();
|
||||
requestAnimationFrame(function () {
|
||||
loadChain();
|
||||
});
|
||||
return;
|
||||
}
|
||||
requestAnimationFrame(function () {
|
||||
loadChain();
|
||||
refreshAllPositions();
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll(".opt-uly-btn").forEach(function (btn) {
|
||||
btn.addEventListener("click", function () {
|
||||
document.querySelectorAll(".opt-uly-btn").forEach(function (b) { b.classList.remove("active"); });
|
||||
@@ -495,7 +522,5 @@
|
||||
});
|
||||
});
|
||||
|
||||
updateSizeInputs();
|
||||
loadChain();
|
||||
refreshAllPositions();
|
||||
bootOptionsPanel();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user