mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #4038 from JDonadio/fix/payment-expired-02
Stop counter when cancel is pressed
This commit is contained in:
commit
346f78c34c
|
@ -504,7 +504,7 @@
|
|||
<a fast-click callback-fn="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a>
|
||||
</div>
|
||||
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}">
|
||||
<button class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline"
|
||||
<button class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline || home.paymentExpired"
|
||||
ng-style="{'background-color':index.backgroundColor}" fast-click callback-fn="home.submitForm()" translate>
|
||||
Send
|
||||
</button>
|
||||
|
|
|
@ -23,6 +23,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
ret.addresses = [];
|
||||
ret.isMobile = isMobile.any();
|
||||
ret.isWindowsPhoneApp = isMobile.Windows() && isCordova;
|
||||
ret.countDown = null;
|
||||
var vanillaScope = ret;
|
||||
|
||||
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) {
|
||||
|
@ -304,6 +305,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
// only determined by the tx.message
|
||||
this.openTxpModal = function(tx, copayers, isGlidera) {
|
||||
$rootScope.modalOpened = true;
|
||||
var self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
var currentSpendUnconfirmed = configWallet.spendUnconfirmed;
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
|
@ -346,18 +348,23 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
function paymentTimeControl(expirationTime) {
|
||||
$scope.paymentExpired = false;
|
||||
var countDown;
|
||||
setExpirationTime();
|
||||
countDown = $interval(function() {
|
||||
|
||||
self.countDown = $interval(function() {
|
||||
setExpirationTime();
|
||||
}, 1000);
|
||||
|
||||
function setExpirationTime() {
|
||||
if (moment().isAfter(expirationTime * 1000)) {
|
||||
var now = Math.floor(Date.now() / 1000);
|
||||
if (now > expirationTime) {
|
||||
$scope.paymentExpired = true;
|
||||
if (countDown) $interval.cancel(countDown);
|
||||
if (self.countDown) $interval.cancel(self.countDown);
|
||||
return;
|
||||
}
|
||||
$scope.expires = moment(expirationTime * 1000).fromNow();
|
||||
var totalSecs = expirationTime - now;
|
||||
var m = Math.floor(totalSecs / 60);
|
||||
var s = totalSecs % 60;
|
||||
$scope.expires = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -994,6 +1001,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
this.resetForm = function() {
|
||||
this.resetError();
|
||||
if (this.countDown) $interval.cancel(this.countDown);
|
||||
this._paypro = null;
|
||||
this.lockedCurrentFeePerKb = null;
|
||||
|
||||
|
@ -1114,25 +1122,31 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
function _paymentTimeControl(expirationTime) {
|
||||
self.paymentExpired = false;
|
||||
var countDown;
|
||||
setExpirationTime();
|
||||
countDown = $interval(function() {
|
||||
|
||||
self.countDown = $interval(function() {
|
||||
setExpirationTime();
|
||||
}, 1000);
|
||||
|
||||
function setExpirationTime() {
|
||||
if (moment().isAfter(expirationTime * 1000)) {
|
||||
setExpiredPaymentValues();
|
||||
if (countDown) $interval.cancel(countDown);
|
||||
var now = Math.floor(Date.now() / 1000);
|
||||
if (now > expirationTime) {
|
||||
setExpiredValues();
|
||||
return;
|
||||
}
|
||||
self.remainingTimeStr = moment(expirationTime * 1000).fromNow();
|
||||
|
||||
var totalSecs = expirationTime - now;
|
||||
var m = Math.floor(totalSecs / 60);
|
||||
var s = totalSecs % 60;
|
||||
self.remainingTimeStr = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
|
||||
};
|
||||
|
||||
function setExpiredPaymentValues() {
|
||||
function setExpiredValues() {
|
||||
self.paymentExpired = true;
|
||||
self.remainingTimeStr = null;
|
||||
self._paypro = null;
|
||||
self.error = gettext('Cannot sign: The payment request has expired');
|
||||
if (self.countDown) $interval.cancel(self.countDown);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue