fix Units in history after change

This commit is contained in:
Matias Alejo Garcia 2015-11-18 10:24:15 -03:00
commit 18ddf8e298

View file

@ -786,11 +786,33 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updateLocalTxHistory = function(client, cb) { self.updateLocalTxHistory = function(client, cb) {
var requestLimit = 6; var requestLimit = 6;
var walletId = client.credentials.walletId; var walletId = client.credentials.walletId;
var config = configService.getSync().wallet.settings;
var fixTxsUnit = function(txs) {
if (!txs || !txs[0]) return;
var cacheUnit = txs[0].amountStr.split(' ')[1];
console.log('[index.js.794:cacheUnit:]', cacheUnit, config.unitName); //TODO
if (cacheUnit == config.unitName)
return;
var name = ' ' + config.unitName;
$log.debug('Fixing Tx Cache Unit to:' + name)
lodash.each(txs, function(tx) {
tx.amountStr = profileService.formatAmount(tx.amount, config.unitName) + name;
tx.feeStr = profileService.formatAmount(tx.fees, config.unitName) + name;
});
};
self.getConfirmedTxs(walletId, function(err, txsFromLocal) { self.getConfirmedTxs(walletId, function(err, txsFromLocal) {
if (err) return cb(err); if (err) return cb(err);
var endingTxid = txsFromLocal[0] ? txsFromLocal[0].txid : null; var endingTxid = txsFromLocal[0] ? txsFromLocal[0].txid : null;
fixTxsUnit(txsFromLocal);
function getNewTxs(newTxs, skip, i_cb) { function getNewTxs(newTxs, skip, i_cb) {
self.getTxsFromServer(client, skip, endingTxid, requestLimit, function(err, res, shouldContinue) { self.getTxsFromServer(client, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
@ -1137,8 +1159,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
$rootScope.$on('Local/UnitSettingUpdated', function(event) { $rootScope.$on('Local/UnitSettingUpdated', function(event) {
self.updateAll(); self.updateAll({
self.updateTxHistory(); triggerTxUpdate: true,
});
self.updateRemotePreferences({ self.updateRemotePreferences({
saveAll: true saveAll: true
}, function() { }, function() {