From 955db5fcfc37c9d68658fb3e631a23688bfbfff5 Mon Sep 17 00:00:00 2001 From: Sonata Green Date: Sat, 20 Aug 2016 16:52:31 -0500 Subject: [PATCH] fix double transactions --- js/page/wallet.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/js/page/wallet.js b/js/page/wallet.js index f5c760a62..34041411b 100644 --- a/js/page/wallet.js +++ b/js/page/wallet.js @@ -131,6 +131,7 @@ var WalletPage = React.createClass({ if (results.length == 0) { out = 'No transactions yet.'; } else { + var condensedTransactions = {}; var rows = []; rows.push( Amount @@ -139,18 +140,29 @@ var WalletPage = React.createClass({ Transaction ); results.forEach(function(tx) { - rows.push( - { (tx["amount"]>0 ? '+' : '' ) + tx["amount"] } - { (new Date(parseInt(tx["time"])*1000)).toLocaleTimeString() } - { (new Date(parseInt(tx["time"])*1000)).toLocaleDateString() } - - - { tx["txid"] } - - - ) + var txid = tx["txid"]; + if (!(txid in condensedTransactions)) { + condensedTransactions[txid] = 0; + } + condensedTransactions[txid] += parseFloat(tx["amount"]); }); - out = {rows}
+ results.forEach(function(tx) { + var txid = tx["txid"]; + var txval = condensedTransactions[txid]; + var txdate = new Date(parseInt(tx["time"])*1000); + if (txid in condensedTransactions && txval != 0) { + rows.push( + { (txval>0 ? '+' : '' ) + txval } + { txdate.toLocaleTimeString() } + { txdate.toLocaleDateString() } + + {txid} + + ); + delete condensedTransactions[tx["txid"]]; + } + }); + out = {rows}
} this.setState({ txlog: out,