Merge pull request #2127 from isocolsky/alt_rate

fixed alternative rate not showing in history
This commit is contained in:
Gustavo Maximiliano Cortez 2014-12-12 17:10:17 -03:00
commit 789d6fbf3b
1 changed files with 6 additions and 6 deletions

View File

@ -122,14 +122,14 @@ angular.module('copayApp.controllers').controller('HistoryController',
$scope._addRates = function(w, txs, cb) { $scope._addRates = function(w, txs, cb) {
if (!txs || txs.length == 0) return 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) { rateService.getHistoricRates(w.settings.alternativeIsoCode, _.keys(index), function(err, res) {
if (err) return cb(err); if (err || !res) return cb(err);
if (!res) return cb();
_.each(res, function(r) { _.each(res, function(r) {
var tx = index[r.ts]; _.each(index[r.ts], function (tx) {
var alternativeAmount = (r.rate != null ? tx.amountSat * rateService.SAT_TO_BTC * r.rate : null); var alternativeAmount = (r.rate != null ? tx.amountSat * rateService.SAT_TO_BTC * r.rate : null);
tx.alternativeAmount = alternativeAmount ? $filter('noFractionNumber')(alternativeAmount, 2) : null; tx.alternativeAmount = alternativeAmount ? $filter('noFractionNumber')(alternativeAmount, 2) : null;
});
}); });
return cb(); return cb();
}); });