aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-15 13:12:50 -0700
committerAdam Soltys <[email protected]>2026-08-15 13:12:50 -0700
commit0b7ae7dbcbfe9688708e5939c94dd01594f43184 (patch)
treedb7e4add2e30cb0cfe754dfda5b67d6532af0652 /src
parentff445296de9c6375c1396d5824eea29d6767e7bb (diff)
downloadcoinosv3-0b7ae7dbcbfe9688708e5939c94dd01594f43184.tar.gz
coinosv3-0b7ae7dbcbfe9688708e5939c94dd01594f43184.zip
A refresh stays where you were: the navigation snapshot in history.state survives reload and is re-applied on boot — profiles, tabs, settings pages all hold their ground
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014tE4U5nEjGTQy8PwYqamfv
Diffstat (limited to 'src')
-rw-r--r--src/app.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/app.js b/src/app.js
index babd095..a47e089 100644
--- a/src/app.js
+++ b/src/app.js
@@ -520,6 +520,20 @@ function syncHistory() {
} catch {} // history API failures must never break a render
}
+// A refresh must land where the user was — on a profile, a settings page, a
+// tab — not back home. history.state survives reload, so the navigation
+// snapshot the last render pushed is still there to re-apply.
+function restoreNavFromHistory() {
+ try {
+ const st = history.state;
+ if (!st || !st.nav || ui.screen !== 'wallet') return;
+ for (const f of NAV_FIELDS) if (f in st.nav) ui[f] = st.nav[f];
+ navStack = [st.nav];
+ navIndex = 0;
+ render();
+ } catch {}
+}
+
window.addEventListener('popstate', (e) => {
const st = e.state;
const snap = (st && st.nav) || navSnapshot();
@@ -1177,6 +1191,7 @@ function restoreAccountsState() {
accounts = sess.accounts;
const active = accounts.find((a) => a.id === sess.activeId) || accounts[0];
activateAccount(active);
+ restoreNavFromHistory();
return true;
}
if (hasVault()) {