diff options
Diffstat (limited to 'src/app.js')
| -rw-r--r-- | src/app.js | 33 |
1 files changed, 26 insertions, 7 deletions
@@ -5186,6 +5186,15 @@ function separateBalances() { function setSeparateBalances(on) { try { on ? localStorage.setItem(SEPARATE_KEY, '1') : localStorage.removeItem(SEPARATE_KEY); } catch {} } +// The one balance's breakdown (Ark / On-chain / Gifts) folds away under its +// total by default (Adam, 2026-11-16); opening it is remembered per device. +const BREAKDOWN_KEY = 'btc-wallet-balance-breakdown'; +function breakdownOpen() { + try { return localStorage.getItem(BREAKDOWN_KEY) === '1'; } catch { return false; } +} +function setBreakdownOpen(on) { + try { on ? localStorage.setItem(BREAKDOWN_KEY, '1') : localStorage.removeItem(BREAKDOWN_KEY); } catch {} +} function unifiedOn(a = activeAccount()) { return !!a && !a.kind && a.type === 'full' && !separateBalances() && spendingActive(); } @@ -5332,8 +5341,8 @@ function walletSide() { h('button', { type: 'button', class: 'wallet-side-total', onClick: () => toWallet('history') }, h('span', { class: 'small muted' }, t('balance')), h('span', { class: 'wallet-side-amount' }, wallet.loaded ? fmtAmount(spending + saving) + ' ' + unitLabel() : '…')), - spendingActive() && (!unified || (spending > 0 && saving > 0)) ? line(unified ? t('balInstant') : t('spendingLabel'), spending) : null, - spendingActive() && (!unified || (spending > 0 && saving > 0)) ? line(unified ? t('balOnchain') : t('savingLabel'), saving) : null, + spendingActive() && (!unified || (spending > 0 && saving > 0 && breakdownOpen())) ? line(unified ? t('balInstant') : t('spendingLabel'), spending) : null, + spendingActive() && (!unified || (spending > 0 && saving > 0 && breakdownOpen())) ? line(unified ? t('balOnchain') : t('savingLabel'), saving) : null, h('div', { class: 'row gap6' }, h('button', { type: 'button', class: 'btn-primary grow', onClick: () => toWallet('receive') }, t('tabReceive')), h('button', { type: 'button', class: 'btn-primary grow', onClick: () => toWallet('send') }, t('tabSend')))), @@ -5473,11 +5482,20 @@ function balanceCard() { // when it's in both places (instant Ark coins, on-chain coins) — and every // line under the figure (pending, moving, locked in gifts) belongs to it. if (unifiedOn()) { - const split = spending > 0 && saving > 0 - ? [{ label: t('balInstant'), sat: spending }, { label: t('balOnchain'), sat: saving }] : []; - const lines = split + // the breakdown (where it sits, what gifts hold) folds away behind a + // toggle; what's on its way (pending, moving) always shows + const split = (spending > 0 && saving > 0 + ? [{ label: t('balInstant'), sat: spending }, { label: t('balOnchain'), sat: saving }] : []) + .concat(featLines.filter((l) => l.part)); + const open = breakdownOpen(); + const lines = (open ? split : []) .concat(pending > 0 ? [{ label: t('pending'), sat: pending, cls: 'v pending' }] : []) - .concat(featLines); + .concat(featLines.filter((l) => !l.part)); + const toggle = split.length + ? h('button', { type: 'button', class: 'linklike small breakdown-toggle', 'aria-expanded': open ? 'true' : 'false', + onClick: () => { setBreakdownOpen(!open); render(); } }, + open ? t('hideBreakdown') + ' ▴' : t('showBreakdown') + ' ▾') + : null; _accDir = null; return h('div', { class: 'card balance balance-one' }, h('div', { class: 'balance-face' }, @@ -5492,7 +5510,8 @@ function balanceCard() { lines.length ? h('div', { class: 'split' }, ...lines.map((l) => h('div', {}, h('div', { class: 'k' }, l.label), h('div', { class: l.cls || 'v' }, fmtAmount(l.sat), ' ', unitTag())))) - : null), + : null, + toggle), ...cardExtras('spending')); } const carouselMode = hasSpending && !kindLocked; |
