Improve wallet transaction display

This commit is contained in:
Unheard0840
2026-08-29 16:03:09 +02:00
parent d4c166b557
commit c66bbfa618
+49 -47
View File
@@ -221,7 +221,7 @@
.wallet-header { .wallet-header {
display: grid; display: grid;
grid-template-columns: minmax(0, 1fr) auto auto auto; grid-template-columns: minmax(0, 1fr) auto auto;
align-items: center; align-items: center;
gap: 24px; gap: 24px;
width: 100%; width: 100%;
@@ -281,13 +281,6 @@
font-weight: 650; font-weight: 650;
} }
.wallet-chevron {
width: 20px;
color: var(--muted);
text-align: center;
font-size: 18px;
}
.wallet-content { .wallet-content {
padding: 0 18px 18px; padding: 0 18px 18px;
border-top: 1px solid var(--border); border-top: 1px solid var(--border);
@@ -1081,6 +1074,38 @@
} }
} }
function formatDateDateOnly(timestamp) {
const value = Number(timestamp);
if (!Number.isFinite(value)) {
return 'Unknown';
}
const date = new Date(value * 1000);
if (Number.isNaN(date.getTime())) {
return 'Unknown';
}
const pad = (number) => String(number).padStart(2, '0');
const year = date.getFullYear();
const shortYear = String(year).slice(-2);
const month = pad(date.getMonth() + 1);
const day = pad(date.getDate());
switch (dateFormat) {
case 'DD.MM.YYYY HH:MM':
case 'DD.MM.YY HH:MM':
return `${day}.${month}.${dateFormat.includes('YYYY') ? year : shortYear}`;
case 'YYYY-MM-DD HH:MM':
return `${year}-${month}-${day}`;
case 'MM/DD/YY HH:MM':
return `${month}/${day}/${shortYear}`;
default:
return `${day}.${month}.${shortYear}`;
}
}
function formatSyncAge(date) { function formatSyncAge(date) {
if (!date) { if (!date) {
return 'Not synced'; return 'Not synced';
@@ -1401,10 +1426,8 @@
const lastActivity = getTransactionDateForLatest(wallet, latest); const lastActivity = getTransactionDateForLatest(wallet, latest);
const lastActivityText = lastActivity const lastActivityText = lastActivity
? formatDate(lastActivity) ? formatDateDateOnly(lastActivity)
: latest : 'No activity';
? `Block ${latest.height}`
: 'No activity';
return ` return `
<article class="wallet"> <article class="wallet">
@@ -1442,10 +1465,6 @@
${escapeHtml(lastActivityText)} ${escapeHtml(lastActivityText)}
</div> </div>
</div> </div>
<div class="wallet-chevron">
${expanded ? 'v' : '>'}
</div>
</button> </button>
${ ${
@@ -1485,11 +1504,7 @@
return ` return `
<div class="wallet-content"> <div class="wallet-content">
<div class="transactions-header"> <div class="transactions-header">
<h3>Transactions</h3> <h3>Transactions (${transactionCount})</h3>
<span class="muted">
${transactionCount}
</span>
</div> </div>
${ ${
@@ -1524,10 +1539,7 @@
const dateText = timestamp const dateText = timestamp
? formatDate(timestamp) ? formatDate(timestamp)
: transaction.height === null || : 'Loading...';
transaction.height === undefined
? 'Pending'
: `Block ${transaction.height}`;
const directionLabel = const directionLabel =
display.direction === 'sent' ? 'Sent' : 'Received'; display.direction === 'sent' ? 'Sent' : 'Received';
@@ -1754,32 +1766,22 @@
const transactions = const transactions =
getWalletTransactions(wallet); getWalletTransactions(wallet);
/*
* Only the latest transaction is loaded
* immediately. The remaining transactions
* are fetched when the user opens them.
*
* This keeps a wallet with many transactions
* from creating dozens of Fulcrum requests
* just by opening it.
*/
if (!transactions.length) { if (!transactions.length) {
return; return;
} }
const latest = /*
transactions[0]; * Load transaction details in parallel so the
* list can populate dates and amounts without
if ( * requiring the user to open each transaction.
!getTransactionFromCache( *
latest.txid, * Cached transactions are skipped by loadTransaction().
) */
) { await Promise.all(
await loadTransaction( transactions.map((transaction) =>
latest.txid, loadTransaction(transaction.txid),
); ),
} );
} }
async function loadTransaction( async function loadTransaction(