From 13b8b81e1131a3a12ef76c95871eadc9ead8a835 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 22 Jun 2017 00:46:35 -0300 Subject: [PATCH] fix paypro --- src/js/controllers/confirm.js | 68 ++++++++++++++++++----------------- www/views/confirm.html | 8 ++--- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index c8c297e88..780f30171 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -22,8 +22,16 @@ angular.module('copayApp.controllers').controller('confirmController', function( var isCordova = platformInfo.isCordova; + function refresh() { + $timeout(function() { + $scope.$apply(); + }, 1); + } + + $scope.showWalletSelector = function() { $scope.walletSelector = true; + refresh(); }; $scope.$on("$ionicView.beforeLeave", function(event, data) { @@ -61,7 +69,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( function setWalletSelector(network, minAmount, cb) { // no min amount? (sendMax) => look for no empty wallets - minAmount = minAmount || 1; + minAmount = minAmount || 1; $scope.wallets = profileService.getWallets({ onlyComplete: true, @@ -133,25 +141,23 @@ angular.module('copayApp.controllers').controller('confirmController', function( // Other Scope vars $scope.isCordova = isCordova; $scope.showAddress = false; - $scope.paymentExpired = { - value: false - }; - $scope.remainingTimeStr = { - value: null - }; - $scope.walletSelectorTitle = gettextCatalog.getString('Send from'); + updateTx(tx, null, {}, function() { - setWalletSelector(tx.network, tx.toAmount, function(err) { - if (err) { - return exitWithError('Could not update wallets'); - } + $scope.walletSelectorTitle = gettextCatalog.getString('Send from'); + + setWalletSelector(tx.network, tx.toAmount, function(err) { + if (err) { + return exitWithError('Could not update wallets'); + } + + if ($scope.wallets.length > 1) { + $scope.showWalletSelector(); + } else if ($scope.wallets.length) { + setWallet($scope.wallets[0], tx); + } + }); - if ($scope.wallets.length > 1) { - $scope.showWalletSelector(); - } else if ($scope.wallets.length) { - setWallet($scope.wallets[0], tx); - } }); }); @@ -226,12 +232,6 @@ angular.module('copayApp.controllers').controller('confirmController', function( $scope.tx = tx; - function refresh() { - $timeout(function() { - $scope.$apply(); - }, 1); - } - function updateAmount() { if (!tx.toAmount) return; @@ -253,6 +253,10 @@ angular.module('copayApp.controllers').controller('confirmController', function( tx.feeRate = feeRate; tx.feeLevelName = feeService.feeOpts[tx.feeLevel]; + // End of quick refresh, before wallet is selected. + if (!wallet) + return cb(); + getSendMaxInfo(lodash.clone(tx), wallet, function(err, sendMaxInfo) { if (err) { var msg = gettextCatalog.getString('Error getting SendMax information'); @@ -270,7 +274,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( } tx.sendMaxInfo = sendMaxInfo; - tx.toAmount =tx.sendMaxInfo.amount; + tx.toAmount = tx.sendMaxInfo.amount; updateAmount(); } refresh(); @@ -397,7 +401,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( }; function _paymentTimeControl(expirationTime) { - $scope.paymentExpired.value = false; + $scope.paymentExpired = false; setExpirationTime(); countDown = $interval(function() { @@ -415,12 +419,12 @@ angular.module('copayApp.controllers').controller('confirmController', function( var totalSecs = expirationTime - now; var m = Math.floor(totalSecs / 60); var s = totalSecs % 60; - $scope.remainingTimeStr.value = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2); + $scope.remainingTimeStr = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2); }; function setExpiredValues() { - $scope.paymentExpired.value = true; - $scope.remainingTimeStr.value = gettextCatalog.getString('Expired'); + $scope.paymentExpired = true; + $scope.remainingTimeStr = gettextCatalog.getString('Expired'); if (countDown) $interval.cancel(countDown); $timeout(function() { $scope.$apply(); @@ -436,9 +440,8 @@ angular.module('copayApp.controllers').controller('confirmController', function( setButtonText(wallet.credentials.m > 1, !!tx.paypro); - //T TODO - if ($scope.paypro) - _paymentTimeControl($scope.paypro.expires); + if (tx.paypro) + _paymentTimeControl(tx.paypro.expires); updateTx(tx, wallet, { dryRun: true @@ -477,8 +480,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( if (!tx || !wallet) return; - // TODO - if (tx.paypro && $scope.paymentExpired.value) { + if ($scope.paymentExpired) { popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.')); $scope.sendStatus = ''; $timeout(function() { diff --git a/www/views/confirm.html b/www/views/confirm.html index ae8158ba9..c576c1320 100644 --- a/www/views/confirm.html +++ b/www/views/confirm.html @@ -23,8 +23,8 @@
Payment Expires: - {{remainingTimeStr.value}} - Expired + {{remainingTimeStr}} + Expired
@@ -61,7 +61,7 @@ {{tx.toAddress}}
- + From
@@ -92,7 +92,7 @@ -
+
{{noWalletMessage}}