From 4983cfb4c49035693f44da26b8f62162fa5279ec Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 14 Jul 2015 11:16:54 -0300 Subject: [PATCH 1/2] Updates getting history to new bws limit --- public/views/walletHome.html | 1 + src/js/controllers/index.js | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/public/views/walletHome.html b/public/views/walletHome.html index 8dc87f9eb..9e87c7d37 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -46,6 +46,7 @@ "> Updating Wallet... Scanning Wallet funds... Recreating Wallet... + Generating .csv file... diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 5787c5f81..633da0001 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -551,7 +551,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r var fs = require('fs'); fs.writeFile(this.value, data, function(err) { if (err) { - console.log(err); + $log.debug(err); } }); }, false); @@ -561,7 +561,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r function formatDate(date) { var dateObj = new Date(date); if (!dateObj) { - log.error('Error formating a date'); + $log.debug('Error formating a date'); return 'DateError' } if (!dateObj.toJSON()) { @@ -585,21 +585,36 @@ angular.module('copayApp.controllers').controller('indexController', function($r return str; } + function getHistory(skip, cb) { + skip = skip || 0; + fc.getTxHistory({ + skip: skip, + limit: 100 + }, function(err, txs) { + if (err) return cb(err); + if (txs && txs.length > 0) { + allTxs.push(txs); + getHistory(skip + 100, cb); + } + else { + return cb(null, lodash.flatten(allTxs)); + } + }); + }; + if (isCordova) { - log.info('Not available on mobile'); + $log.info('Not available on mobile'); return; } var isNode = nodeWebkit.isDefined(); var fc = profileService.focusedClient; if (!fc.isComplete()) return; var self = this; + var allTxs = []; $log.debug('Generating CSV from History'); self.setOngoingProcess('generatingCSV', true); $timeout(function() { - fc.getTxHistory({ - skip: 0, - limit: 1000000000 - }, function(err, txs) { + getHistory(null, function(err, txs) { self.setOngoingProcess('generatingCSV', false); if (err) { $log.debug('TxHistory ERROR:', err); From 7945e9ca59c6c93800a3a9e3cdbd11a0fc548f53 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 14 Jul 2015 12:19:22 -0300 Subject: [PATCH 2/2] Adds return --- src/js/controllers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 633da0001..9048332ca 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -594,7 +594,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r if (err) return cb(err); if (txs && txs.length > 0) { allTxs.push(txs); - getHistory(skip + 100, cb); + return getHistory(skip + 100, cb); } else { return cb(null, lodash.flatten(allTxs));