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

@ -142,7 +142,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
var defaults = configService.getDefaults();
var config = configService.getSync();
self.usingCustomBWS = config.bwsFor && config.bwsFor[self.walletId] && (config.bwsFor[self.walletId] != defaults.bws.url);
self.usingCustomBWS = config.bwsFor && config.bwsFor[self.walletId] && (config.bwsFor[self.walletId] != defaults.bws.url);
};
self.setTab = function(tab, reset, tries, switchState) {
@ -786,11 +786,33 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updateLocalTxHistory = function(client, cb) {
var requestLimit = 6;
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) {
if (err) return cb(err);
var endingTxid = txsFromLocal[0] ? txsFromLocal[0].txid : null;
fixTxsUnit(txsFromLocal);
function getNewTxs(newTxs, skip, i_cb) {
self.getTxsFromServer(client, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
@ -807,7 +829,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
return i_cb(null, newTxs);
}
if (walletId == profileService.focusedClient.credentials.walletId)
if (walletId == profileService.focusedClient.credentials.walletId)
self.txProgress = newTxs.length;
$timeout(function() {
@ -822,7 +844,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
var newHistory = lodash.compact(txs.concat(txsFromLocal));
$log.debug('Tx History synced. Total Txs: ' + newHistory.length);
if (walletId == profileService.focusedClient.credentials.walletId) {
if (walletId == profileService.focusedClient.credentials.walletId) {
self.completeHistory = newHistory;
self.txHistory = newHistory.slice(0, self.historyShowLimit);
self.historyShowShowAll = newHistory.length >= self.historyShowLimit;
@ -1137,8 +1159,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
$rootScope.$on('Local/UnitSettingUpdated', function(event) {
self.updateAll();
self.updateTxHistory();
self.updateAll({
triggerTxUpdate: true,
});
self.updateRemotePreferences({
saveAll: true
}, function() {