use cached history first

This commit is contained in:
Javier 2016-09-20 16:45:43 -03:00
commit 9ce67ed68a

View file

@ -503,15 +503,23 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
}; };
root.getTx = function(wallet, txid, cb) { root.getTx = function(wallet, txid, cb) {
root.getTxHistory(wallet, {}, function(err, txHistory) { if (wallet.completeHistory && wallet.completeHistory.isValid) {
if (err) return cb(err); var tx = lodash.find(wallet.completeHistory, {
var tx = lodash.find(txHistory, {
txid: txid txid: txid
}); });
return cb(null, tx); return cb(null, tx);
}); } else {
root.getTxHistory(wallet, {}, function(err, txHistory) {
if (err) return cb(err);
var tx = lodash.find(txHistory, {
txid: txid
});
return cb(null, tx);
});
}
}; };
root.getTxHistory = function(wallet, opts, cb) { root.getTxHistory = function(wallet, opts, cb) {