stop counter when cancel is pressed

This commit is contained in:
Javier 2016-03-30 12:52:19 -03:00
commit e80eb142e3
2 changed files with 13 additions and 9 deletions

View file

@ -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>

View file

@ -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,16 +348,16 @@ 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)) {
$scope.paymentExpired = true;
if (countDown) $interval.cancel(countDown);
if (self.countDown) $interval.cancel(self.countDown);
}
$scope.expires = moment(expirationTime * 1000).fromNow();
};
@ -994,6 +996,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 +1117,26 @@ 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);
setExpiredValues();
return;
}
self.remainingTimeStr = moment(expirationTime * 1000).fromNow();
};
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);
};
};