From 9db19422e4d48e40934c74a7cf14d433cd88fb46 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Tue, 4 Nov 2014 10:56:13 -0300 Subject: [PATCH] compute alternative currency for pending txps --- js/services/controllerUtils.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 52b37c4c9..ee5129272 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -324,6 +324,17 @@ angular.module('copayApp.services') }; root.updateTxs = function(opts) { + function computeAlternativeAmount(w, tx, cb) { + rateService.whenAvailable(function() { + _.each(tx.outs, function(out) { + var valueSat = out.value * w.settings.unitToSatoshi; + out.alternativeAmount = rateService.toFiat(valueSat, w.settings.alternativeIsoCode); + out.alternativeIsoCode = w.settings.alternativeIsoCode; + }); + if (cb) return cb(); + }); + }; + var w = opts.wallet || $rootScope.wallet; if (!w) return; opts = opts || $rootScope.txsOpts || {}; @@ -364,6 +375,9 @@ angular.module('copayApp.services') i.fee = i.builder.feeSat * satToUnit; i.missingSignatures = tx.countInputMissingSignatures(0); i.actionList = getActionList(i.peerActions); + if (i.isPending) { + computeAlternativeAmount(w, i); + } txs.push(i); } });