diff options
author | Florian Dold <florian@dold.me> | 2023-10-10 12:14:09 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-10-10 12:14:15 +0200 |
commit | adda4f8ce38ce030f55855bc0d66443d08153480 (patch) | |
tree | d24f0fbe48419b6d89e86b7663e8d64599a1f039 /packages | |
parent | 4e11051d9fccdbdd40abaa630afc130eafef6602 (diff) |
wallet-core: order transactions by descending timestamp
Diffstat (limited to 'packages')
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index cf2006406..72c67b153 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -1291,10 +1291,12 @@ export async function getTransactions( const txNotPending = transactions.filter((x) => !isPending(x)); const txCmp = (h1: Transaction, h2: Transaction) => { - const tsCmp = AbsoluteTime.cmp( + // Order transactions by timestamp. Newest transactions come first. + const tsCmp = -AbsoluteTime.cmp( AbsoluteTime.fromPreciseTimestamp(h1.timestamp), AbsoluteTime.fromPreciseTimestamp(h2.timestamp), ); + // If the timestamp is exactly the same, order by transaction type. if (tsCmp === 0) { return Math.sign(txOrder[h1.type] - txOrder[h2.type]); } |