From 923eeb909d94bf5ae3193206651f700537ef76de Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 18 May 2017 18:51:49 -0300 Subject: [PATCH] Fix getTx info if it is not in cache --- src/js/controllers/tx-details.js | 6 ++++-- src/js/services/walletService.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/js/controllers/tx-details.js b/src/js/controllers/tx-details.js index 5e6e2b886..408c90eca 100644 --- a/src/js/controllers/tx-details.js +++ b/src/js/controllers/tx-details.js @@ -20,7 +20,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio listeners = [ $rootScope.$on('bwsEvent', function(e, walletId, type, n) { if (type == 'NewBlock' && n && n.data && n.data.network == 'livenet') { - updateTx({hideLoading: true}); + updateTxDebounced({hideLoading: true}); } }) ]; @@ -97,7 +97,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio walletService.getTx($scope.wallet, txId, function(err, tx) { if (!opts.hideLoading) ongoingProcess.set('loadingTxInfo', false); if (err) { - $log.warn('Error getting transaction' + err); + $log.warn('Error getting transaction: ' + err); $ionicHistory.goBack(); return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not available at this time')); } @@ -124,6 +124,8 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio }); }); }; + + var updateTxDebounced = lodash.debounce(updateTx, 5000); $scope.showCommentPopup = function() { var opts = {}; diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index 3c6b50e57..b619c80af 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -457,13 +457,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim // do not sync all history, just looking for a single TX. if (opts.limitTx) { - foundLimitTx = lodash.find(newTxs, { + foundLimitTx = lodash.find(txsFromLocal, { txid: opts.limitTx, }); if (foundLimitTx) { $log.debug('Found limitTX: ' + opts.limitTx); - return next(null, newTxs); + return next(null, [foundLimitTx]); } } //