Prevent double tap (in mobile)

This commit is contained in:
Gustavo Maximiliano Cortez 2016-08-01 14:16:47 -03:00
commit b210a970d3
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
2 changed files with 82 additions and 76 deletions

View file

@ -27,46 +27,49 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.error = null; $scope.error = null;
$scope.loading = 'Signing Transaction'; $scope.loading = 'Signing Transaction';
fingerprintService.check(fc, function(err) { $timeout(function() {
if (err) {
$scope.error = bwcError.msg(err);
$scope.loading = null;
return;
}
handleEncryptedWallet(function(err) { fingerprintService.check(fc, function(err) {
if (err) { if (err) {
$scope.error = bwcError.msg(err); $scope.error = bwcError.msg(err);
$scope.loading = null; $scope.loading = null;
return; return;
} }
walletService.signTx(fc, txp, function(err, signedTxp) { handleEncryptedWallet(function(err) {
walletService.lock(fc);
if (err) { if (err) {
$scope.error = bwcError.msg(err); $scope.error = bwcError.msg(err);
$scope.loading = null; $scope.loading = null;
return; return;
} }
if (signedTxp.status == 'accepted') { walletService.signTx(fc, txp, function(err, signedTxp) {
$scope.loading = 'Broadcasting Transaction'; walletService.lock(fc);
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) { if (err) {
$scope.error = bwcError.msg(err);
$scope.loading = null;
return;
}
if (signedTxp.status == 'accepted') {
$scope.loading = 'Broadcasting Transaction';
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) {
$scope.loading = null;
$scope.$emit('UpdateTx');
$scope.close(broadcastedTxp);
if (err) {
$scope.error = err;
}
});
} else {
$scope.loading = null; $scope.loading = null;
$scope.$emit('UpdateTx'); $scope.$emit('UpdateTx');
$scope.close(broadcastedTxp); $scope.close(signedTxp);
if (err) { }
$scope.error = err; });
}
});
} else {
$scope.loading = null;
$scope.$emit('UpdateTx');
$scope.close(signedTxp);
}
}); });
}); });
}); }, 10);
}; };
$scope.reject = function(txp) { $scope.reject = function(txp) {

View file

@ -823,70 +823,73 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.error = null; this.error = null;
ongoingProcess.set('calculatingFee', true); ongoingProcess.set('calculatingFee', true);
feeService.getCurrentFeeValue(function(err, feePerKb) { $timeout(function() {
ongoingProcess.set('calculatingFee', false);
if (err || !lodash.isNumber(feePerKb)) {
self.error = gettext('Could not get fee value');
return;
}
var opts = {}; feeService.getCurrentFeeValue(function(err, feePerKb) {
opts.feePerKb = feePerKb; ongoingProcess.set('calculatingFee', false);
opts.returnInputs = true; if (err || !lodash.isNumber(feePerKb)) {
var config = configService.getSync(); self.error = gettext('Could not get fee value');
opts.excludeUnconfirmedUtxos = !config.wallet.spendUnconfirmed;
ongoingProcess.set('retrivingInputs', true);
fc.getSendMaxInfo(opts, function(err, resp) {
ongoingProcess.set('retrivingInputs', false);
if (err) {
self.error = err;
$scope.$apply();
return; return;
} }
if (resp.amount == 0) { var opts = {};
self.error = gettext("Not enough funds for fee"); opts.feePerKb = feePerKb;
$scope.$apply(); opts.returnInputs = true;
return; var config = configService.getSync();
} opts.excludeUnconfirmedUtxos = !config.wallet.spendUnconfirmed;
ongoingProcess.set('retrivingInputs', true);
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", { fc.getSendMaxInfo(opts, function(err, resp) {
fee: profileService.formatAmount(resp.fee) + ' ' + self.unitName ongoingProcess.set('retrivingInputs', false);
});
var warningMsg = verifyExcludedUtxos(); if (err) {
self.error = err;
$scope.$apply();
return;
}
if (!lodash.isEmpty(warningMsg)) if (resp.amount == 0) {
msg += '. \n' + warningMsg; self.error = gettext("Not enough funds for fee");
$scope.$apply();
return;
}
confirmDialog.show(msg, function(confirmed) { var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", {
if (confirmed) { fee: profileService.formatAmount(resp.fee) + ' ' + self.unitName
self.sendMaxInfo = resp; });
var amount = parseFloat((resp.amount * self.satToUnit).toFixed(self.unitDecimals));
self.setForm(null, amount, null); var warningMsg = verifyExcludedUtxos();
} else {
self.resetForm(); if (!lodash.isEmpty(warningMsg))
msg += '. \n' + warningMsg;
confirmDialog.show(msg, function(confirmed) {
if (confirmed) {
self.sendMaxInfo = resp;
var amount = parseFloat((resp.amount * self.satToUnit).toFixed(self.unitDecimals));
self.setForm(null, amount, null);
} else {
self.resetForm();
}
});
function verifyExcludedUtxos() {
var warningMsg = [];
if (resp.utxosBelowFee > 0) {
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", {
amountBelowFeeStr: profileService.formatAmount(resp.amountBelowFee) + ' ' + self.unitName
}));
}
if (resp.utxosAboveMaxSize > 0) {
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded", {
amountAboveMaxSizeStr: profileService.formatAmount(resp.amountAboveMaxSize) + ' ' + self.unitName
}));
}
return warningMsg.join('\n');
} }
}); });
function verifyExcludedUtxos() {
var warningMsg = [];
if (resp.utxosBelowFee > 0) {
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", {
amountBelowFeeStr: profileService.formatAmount(resp.amountBelowFee) + ' ' + self.unitName
}));
}
if (resp.utxosAboveMaxSize > 0) {
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded", {
amountAboveMaxSizeStr: profileService.formatAmount(resp.amountAboveMaxSize) + ' ' + self.unitName
}));
}
return warningMsg.join('\n');
}
}); });
}); }, 10);
}; };
/* Start setup */ /* Start setup */