refactor quiet

This commit is contained in:
Matias Alejo Garcia 2015-06-19 15:09:15 -03:00
parent 206fe41db5
commit 7e23bd3406
2 changed files with 25 additions and 14 deletions

View File

@ -279,8 +279,9 @@
<h4 class="title m0">
<button class="outline light-gray round tiny right m0 lh"
ng-if="index.feeToSendMaxStr && index.availableBalance > 0 && !home.blockUx && !home.lockAmount"
ng-click="home.sendAll(index.availableMaxBalance, index.feeToSendMaxStr)"
ng-if="index.availableBalance > 0 && !home.blockUx && !home.lockAmount" translate> Send All
translate> Send All
</button>
<div ng-show="!index.lockedBalance && index.availableBalanceStr">

View File

@ -57,9 +57,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
isoCode: 'pt',
}];
self.setOngoingProcess = function(processName, isOn, quiet) {
self.setOngoingProcess = function(processName, isOn) {
$log.debug('onGoingProcess', processName, isOn);
if (quiet) return;
self[processName] = isOn;
self.onGoingProcess[processName] = isOn;
@ -179,13 +178,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updateAll = function(opts, initStatusHash, tries) {
tries = tries || 0;
var quiet = (opts && opts.quiet) ? true : null;
if (opts && opts.untilItChanges && lodash.isUndefined(initStatusHash)) {
opts = opts || {};
if (opts.untilItChanges && lodash.isUndefined(initStatusHash)) {
initStatusHash = _walletStatusHash();
$log.debug('Updating status until it changes. initStatusHash:' + initStatusHash)
}
var get = function(cb) {
if (opts && opts.walletStatus)
if (opts.walletStatus)
return cb(null, opts.walletStatus);
else {
self.updateError = false;
@ -193,7 +193,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
if (err) {
self.updateError = true;
} else {
self.setOngoingProcess('scanning', ret.wallet.scanning, quiet);
if (!opts.quiet)
self.setOngoingProcess('scanning', ret.wallet.scanning);
}
return cb(err, ret);
});
@ -204,18 +205,23 @@ angular.module('copayApp.controllers').controller('indexController', function($r
if (!fc) return;
$timeout(function() {
self.setOngoingProcess('updatingStatus', true, quiet);
if (!opts.quiet)
self.setOngoingProcess('updatingStatus', true);
$log.debug('Updating Status:', fc, tries);
get(function(err, walletStatus) {
var currentStatusHash = _walletStatusHash(walletStatus);
$log.debug('Status update. hash:' + currentStatusHash + ' Try:'+ tries);
if (!err && (opts && opts.untilItChanges) && initStatusHash == currentStatusHash && tries < 7) {
if (!err && opts.untilItChanges && initStatusHash == currentStatusHash && tries < 7) {
return $timeout(function() {
$log.debug('Retrying update... Try:' + tries)
return self.updateAll({walletStatus: null, untilItChanges: true}, initStatusHash, ++tries);
}, 1400 * tries);
}
self.setOngoingProcess('updatingStatus', false, quiet);
if (!opts.quiet)
self.setOngoingProcess('updatingStatus', false);
if (err) {
self.handleError(err);
return;
@ -437,11 +443,15 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.availableBalanceBTC = strip(self.availableBalanceBTC / COIN);
// KB to send max
self.feePerKbSat = config.feePerKbSat || 10000;
var feeToSendMaxSat = balance.totalKbToSendMax * self.feePerKbSat;
self.feePerKbSat = config.feePerKbSat || 10000;
if (balance.totalKbToSendMax) {
var feeToSendMaxSat = balance.totalKbToSendMax * self.feePerKbSat;
self.availableMaxBalance = strip((self.availableBalanceSat - feeToSendMaxSat) * self.satToUnit);
self.feeToSendMaxStr = profileService.formatAmount(feeToSendMaxSat) + ' ' + self.unitName;
self.availableMaxBalance = strip((self.availableBalanceSat - feeToSendMaxSat) * self.satToUnit);
self.feeToSendMaxStr = profileService.formatAmount(feeToSendMaxSat) + ' ' + self.unitName;
} else {
self.feeToSendMaxStr = null;
}
//STR
self.totalBalanceStr = profileService.formatAmount(self.totalBalanceSat) + ' ' + self.unitName;