Merge pull request #6073 from cmgustavo/bug/tx-details-no-cached

Fix getTx info if it is not in cache
This commit is contained in:
Gabriel Edgardo Bazán 2017-05-23 11:11:04 -03:00 committed by GitHub
commit 296637c299
2 changed files with 6 additions and 4 deletions

View file

@ -20,7 +20,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
listeners = [ listeners = [
$rootScope.$on('bwsEvent', function(e, walletId, type, n) { $rootScope.$on('bwsEvent', function(e, walletId, type, n) {
if (type == 'NewBlock' && n && n.data && n.data.network == 'livenet') { 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) { walletService.getTx($scope.wallet, txId, function(err, tx) {
if (!opts.hideLoading) ongoingProcess.set('loadingTxInfo', false); if (!opts.hideLoading) ongoingProcess.set('loadingTxInfo', false);
if (err) { if (err) {
$log.warn('Error getting transaction' + err); $log.warn('Error getting transaction: ' + err);
$ionicHistory.goBack(); $ionicHistory.goBack();
return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not available at this time')); return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not available at this time'));
} }
@ -125,6 +125,8 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
}); });
}; };
var updateTxDebounced = lodash.debounce(updateTx, 5000);
$scope.showCommentPopup = function() { $scope.showCommentPopup = function() {
var opts = {}; var opts = {};
if ($scope.btx.message) { if ($scope.btx.message) {

View file

@ -457,13 +457,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
// do not sync all history, just looking for a single TX. // do not sync all history, just looking for a single TX.
if (opts.limitTx) { if (opts.limitTx) {
foundLimitTx = lodash.find(newTxs, { foundLimitTx = lodash.find(txsFromLocal, {
txid: opts.limitTx, txid: opts.limitTx,
}); });
if (foundLimitTx) { if (foundLimitTx) {
$log.debug('Found limitTX: ' + opts.limitTx); $log.debug('Found limitTX: ' + opts.limitTx);
return next(null, newTxs); return next(null, [foundLimitTx]);
} }
} }
// </HACK> // </HACK>