diff --git a/index.html b/index.html index b5aef3a5d..b30118510 100644 --- a/index.html +++ b/index.html @@ -328,10 +328,10 @@ -
+

Last transactions

-
-
+
+
diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index aee87b56e..a2e8a3697 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -69,13 +69,14 @@ console.log('[transactions.js.68:txid:] SENTTX CALLBACK',txid); //TODO $scope.getTransactions = function() { var w =$rootScope.wallet; - var addresses = w.getAddressesStr(true); + var addresses = w.getAddressesStr(); - w.blockchain.getTransactions(addresses, function(txs) { - $scope.blockchain_txs = txs; - $scope.$digest(); - }); - + if (addresses.length > 0) { + w.blockchain.getTransactions(addresses, function(txs) { + $scope.blockchain_txs = txs; + $rootScope.$digest(); + }); + } }; _updateTxs(); diff --git a/js/models/blockchain/Insight.js b/js/models/blockchain/Insight.js index 0bcca1a72..7fa1b275f 100644 --- a/js/models/blockchain/Insight.js +++ b/js/models/blockchain/Insight.js @@ -27,7 +27,31 @@ function _asyncForEach(array, fn, callback) { } else { callback(); // Done! } -}; +}; + +function removeRepeatedElements(ar){ + var ya=false,v="",aux=[].concat(ar),r=Array(); + for (var i in aux){ // + v=aux[i]; + ya=false; + for (var a in aux){ + if (v==aux[a]){ + if (ya==false){ + ya=true; + } + else{ + aux[a]=""; + } + } + } + } + for (var a in aux){ + if (aux[a]!=""){ + r.push(aux[a]); + } + } + return r; +} Insight.prototype.getTransactions = function(addresses, cb) { var self = this; @@ -56,7 +80,8 @@ Insight.prototype.getTransactions = function(addresses, cb) { callback(); }); }, function() { - _asyncForEach(txids, function(txid, callback2) { + var clean_txids = removeRepeatedElements(txids); + _asyncForEach(clean_txids, function(txid, callback2) { var options = { host: self.host, port: self.port,