From 0b7ae7dbcbfe9688708e5939c94dd01594f43184 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 15 Aug 2026 13:12:50 -0700 Subject: 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_014tE4U5nEjGTQy8PwYqamfv --- src/app.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') 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()) { -- cgit v1.2.3