From b210a970d3e3de90de1f9f1bc8099c358bc5ae03 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 1 Aug 2016 14:16:47 -0300 Subject: [PATCH] Prevent double tap (in mobile) --- src/js/controllers/modals/txpDetails.js | 49 ++++++----- src/js/controllers/walletHome.js | 109 ++++++++++++------------ 2 files changed, 82 insertions(+), 76 deletions(-) diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js index 3e34bc67a..2ccc77021 100644 --- a/src/js/controllers/modals/txpDetails.js +++ b/src/js/controllers/modals/txpDetails.js @@ -27,46 +27,49 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi $scope.error = null; $scope.loading = 'Signing Transaction'; - fingerprintService.check(fc, function(err) { - if (err) { - $scope.error = bwcError.msg(err); - $scope.loading = null; - return; - } + $timeout(function() { - handleEncryptedWallet(function(err) { + fingerprintService.check(fc, function(err) { if (err) { $scope.error = bwcError.msg(err); $scope.loading = null; return; } - walletService.signTx(fc, txp, function(err, signedTxp) { - walletService.lock(fc); + handleEncryptedWallet(function(err) { 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) { + walletService.signTx(fc, txp, function(err, signedTxp) { + walletService.lock(fc); + 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.$emit('UpdateTx'); - $scope.close(broadcastedTxp); - if (err) { - $scope.error = err; - } - }); - } else { - $scope.loading = null; - $scope.$emit('UpdateTx'); - $scope.close(signedTxp); - } + $scope.close(signedTxp); + } + }); }); }); - }); + }, 10); }; $scope.reject = function(txp) { diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index 878497619..05bfc5dc9 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -823,70 +823,73 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi this.error = null; ongoingProcess.set('calculatingFee', true); - feeService.getCurrentFeeValue(function(err, feePerKb) { - ongoingProcess.set('calculatingFee', false); - if (err || !lodash.isNumber(feePerKb)) { - self.error = gettext('Could not get fee value'); - return; - } + $timeout(function() { - var opts = {}; - opts.feePerKb = feePerKb; - opts.returnInputs = true; - var config = configService.getSync(); - 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(); + feeService.getCurrentFeeValue(function(err, feePerKb) { + ongoingProcess.set('calculatingFee', false); + if (err || !lodash.isNumber(feePerKb)) { + self.error = gettext('Could not get fee value'); return; } - if (resp.amount == 0) { - self.error = gettext("Not enough funds for fee"); - $scope.$apply(); - return; - } + var opts = {}; + opts.feePerKb = feePerKb; + opts.returnInputs = true; + 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", { - fee: profileService.formatAmount(resp.fee) + ' ' + self.unitName - }); + fc.getSendMaxInfo(opts, function(err, resp) { + ongoingProcess.set('retrivingInputs', false); - var warningMsg = verifyExcludedUtxos(); + if (err) { + self.error = err; + $scope.$apply(); + return; + } - if (!lodash.isEmpty(warningMsg)) - msg += '. \n' + warningMsg; + if (resp.amount == 0) { + self.error = gettext("Not enough funds for fee"); + $scope.$apply(); + return; + } - 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(); + var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", { + fee: profileService.formatAmount(resp.fee) + ' ' + self.unitName + }); + + var warningMsg = verifyExcludedUtxos(); + + 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 */