diff options
| author | Adam Soltys <[email protected]> | 2026-06-25 17:10:23 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-06-25 17:10:23 -0700 |
| commit | fb420c0b73101a1c1beb5ca544380a9860823ec3 (patch) | |
| tree | 4df16c18e3e557d48ae76dfb8615bd07256ae18f /src/app.js | |
| parent | 3d57ac2a6f70a7b881d9f1fd2d9d304c2f0ba2a3 (diff) | |
| download | coinosv3-fb420c0b73101a1c1beb5ca544380a9860823ec3.tar.gz coinosv3-fb420c0b73101a1c1beb5ca544380a9860823ec3.zip | |
Persist the active tab + open tx across refresh
Save the wallet-screen nav (tab and open tx detail) to sessionStorage on each
render and restore it on load, so refreshing keeps your place instead of jumping
back to Receive. A restored tx detail re-fetches its fee/details if missing.
Gift links still open the claim screen.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'src/app.js')
| -rw-r--r-- | src/app.js | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -221,6 +221,9 @@ function openHowItWorks() { render(); } +// Per-tab session nav (tab + open tx), so a refresh keeps the user's place. +const NAV_KEY = 'btc-wallet-nav'; + function render() { const screen = ui.screen === 'wallet' @@ -238,6 +241,10 @@ function render() { // Fast-poll the receive address only while the user is actually watching for a // payment (wallet screen, Receive tab, online). Idempotent — safe each render. wallet.setWatchReceive(ui.screen === 'wallet' && ui.tab === 'receive' && !wallet.offline); + // Remember where we are so a refresh restores it (only meaningful on the wallet). + if (ui.screen === 'wallet') { + try { sessionStorage.setItem(NAV_KEY, JSON.stringify({ tab: ui.tab, txDetail: ui.txDetail })); } catch {} + } } wallet.subscribe(render); @@ -605,7 +612,11 @@ async function activateAccount(acc, opts = {}) { ui.claimError = ''; ui.claimTaken = null; ui.claimChecking = !!opts.gift; // gate the Claim button until we've checked - ui.tab = 'receive'; + // Restore the tab / open tx from the last session so a refresh keeps the + // user's place. A gift link always opens the claim screen instead. + const nav = (() => { try { return JSON.parse(sessionStorage.getItem(NAV_KEY) || 'null'); } catch { return null; } })(); + ui.tab = (!opts.gift && nav && nav.tab) || 'receive'; + ui.txDetail = (!opts.gift && nav && nav.txDetail) || null; // Not baselined yet — stays null until the scan + ack logic below sets it, // so the celebration never fires for payments that were already there at // import (the index only looks "advanced" because the scan hadn't run yet). @@ -616,6 +627,7 @@ async function activateAccount(acc, opts = {}) { ui.giftMode = false; ui.offlineFallback = false; render(); + if (ui.txDetail) openTx(ui.txDetail); // restored a tx detail — fill in fee/details if missing // No manual offline switch: try to scan, and if the network is unreachable, // fall back to offline mode automatically. |
