From cdbbad9f2262eb4e8ce88c058a8455d83e2fab8b Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Fri, 12 Dec 2014 16:38:35 -0300 Subject: [PATCH] fixed alternative rate not showing in history --- js/controllers/history.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/controllers/history.js b/js/controllers/history.js index f35e926ab..e546ab3cf 100644 --- a/js/controllers/history.js +++ b/js/controllers/history.js @@ -122,14 +122,14 @@ angular.module('copayApp.controllers').controller('HistoryController', $scope._addRates = function(w, txs, cb) { if (!txs || txs.length == 0) return cb(); - var index = _.indexBy(txs, 'rateTs'); + var index = _.groupBy(txs, 'rateTs'); rateService.getHistoricRates(w.settings.alternativeIsoCode, _.keys(index), function(err, res) { - if (err) return cb(err); - if (!res) return cb(); + if (err || !res) return cb(err); _.each(res, function(r) { - var tx = index[r.ts]; - var alternativeAmount = (r.rate != null ? tx.amountSat * rateService.SAT_TO_BTC * r.rate : null); - tx.alternativeAmount = alternativeAmount ? $filter('noFractionNumber')(alternativeAmount, 2) : null; + _.each(index[r.ts], function (tx) { + var alternativeAmount = (r.rate != null ? tx.amountSat * rateService.SAT_TO_BTC * r.rate : null); + tx.alternativeAmount = alternativeAmount ? $filter('noFractionNumber')(alternativeAmount, 2) : null; + }); }); return cb(); });