lock form inputs during fetch. add fetch timeout. see bitpay/bitcore#518. see #1508.
This commit is contained in:
parent
e81f2e7c36
commit
313f7eaaae
1 changed files with 32 additions and 11 deletions
|
|
@ -522,11 +522,36 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var apply = function() {
|
||||||
|
if ($rootScope.$$phase !== '$apply' && $rootScope.$$phase !== '$digest') {
|
||||||
|
$rootScope.$apply();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
notification.info('Fetching Payment',
|
notification.info('Fetching Payment',
|
||||||
'Retrieving Payment Request from ' + uri.merchant);
|
'Retrieving Payment Request from ' + uri.merchant);
|
||||||
|
|
||||||
|
scope.loading = true;
|
||||||
|
apply();
|
||||||
|
|
||||||
|
var timeout = setTimeout(function() {
|
||||||
|
timeout = null;
|
||||||
|
scope.loading = false;
|
||||||
|
scope.sendForm.address.$setViewValue('');
|
||||||
|
scope.sendForm.address.$render();
|
||||||
|
scope.sendForm.address.$isValid = false;
|
||||||
|
notification.error('Error', 'Payment server timed out.');
|
||||||
|
apply();
|
||||||
|
}, 10 * 1000);
|
||||||
|
|
||||||
// Payment Protocol URI (BIP-72)
|
// Payment Protocol URI (BIP-72)
|
||||||
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
|
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
|
||||||
|
if (!timeout) return;
|
||||||
|
clearTimeout(timeout);
|
||||||
|
|
||||||
|
scope.loading = false;
|
||||||
|
apply();
|
||||||
|
|
||||||
var balance = $rootScope.availableBalance;
|
var balance = $rootScope.availableBalance;
|
||||||
var available = +(balance * w.settings.unitToSatoshi).toFixed(0);
|
var available = +(balance * w.settings.unitToSatoshi).toFixed(0);
|
||||||
|
|
||||||
|
|
@ -536,8 +561,6 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
scope.sendForm.address.$isValid = false;
|
|
||||||
|
|
||||||
if (err.amount) {
|
if (err.amount) {
|
||||||
scope.sendForm.amount.$setViewValue(+err.amount / w.settings.unitToSatoshi);
|
scope.sendForm.amount.$setViewValue(+err.amount / w.settings.unitToSatoshi);
|
||||||
scope.sendForm.amount.$render();
|
scope.sendForm.amount.$render();
|
||||||
|
|
@ -551,18 +574,18 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
scope.sendForm.amount.$setViewValue('');
|
scope.sendForm.amount.$setViewValue('');
|
||||||
scope.sendForm.amount.$render();
|
scope.sendForm.amount.$render();
|
||||||
unregister();
|
unregister();
|
||||||
if ($rootScope.$$phase !== '$apply' && $rootScope.$$phase !== '$digest') {
|
apply();
|
||||||
$rootScope.$apply();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
scope.sendForm.address.$setViewValue('');
|
||||||
|
scope.sendForm.address.$render();
|
||||||
}
|
}
|
||||||
|
scope.sendForm.address.$isValid = false;
|
||||||
|
|
||||||
notification.error('Error', err.message || 'Bad payment server.');
|
notification.error('Error', err.message || 'Bad payment server.');
|
||||||
|
|
||||||
if ($rootScope.$$phase !== '$apply' && $rootScope.$$phase !== '$digest') {
|
apply();
|
||||||
$rootScope.$apply();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -590,9 +613,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
$scope.clearMerchant(unregister);
|
$scope.clearMerchant(unregister);
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($rootScope.$$phase !== '$apply' && $rootScope.$$phase !== '$digest') {
|
apply();
|
||||||
$rootScope.$apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
notification.info('Payment Request',
|
notification.info('Payment Request',
|
||||||
'Server is requesting ' + merchantData.unitTotal +
|
'Server is requesting ' + merchantData.unitTotal +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue