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> <a fast-click callback-fn="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a>
</div> </div>
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}"> <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> ng-style="{'background-color':index.backgroundColor}" fast-click callback-fn="home.submitForm()" translate>
Send Send
</button> </button>

View file

@ -23,6 +23,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
ret.addresses = []; ret.addresses = [];
ret.isMobile = isMobile.any(); ret.isMobile = isMobile.any();
ret.isWindowsPhoneApp = isMobile.Windows() && isCordova; ret.isWindowsPhoneApp = isMobile.Windows() && isCordova;
ret.countDown = null;
var vanillaScope = ret; var vanillaScope = ret;
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) { 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 // only determined by the tx.message
this.openTxpModal = function(tx, copayers, isGlidera) { this.openTxpModal = function(tx, copayers, isGlidera) {
$rootScope.modalOpened = true; $rootScope.modalOpened = true;
var self = this;
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
var currentSpendUnconfirmed = configWallet.spendUnconfirmed; var currentSpendUnconfirmed = configWallet.spendUnconfirmed;
var ModalInstanceCtrl = function($scope, $modalInstance) { var ModalInstanceCtrl = function($scope, $modalInstance) {
@ -346,16 +348,16 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
function paymentTimeControl(expirationTime) { function paymentTimeControl(expirationTime) {
$scope.paymentExpired = false; $scope.paymentExpired = false;
var countDown;
setExpirationTime(); setExpirationTime();
countDown = $interval(function() {
self.countDown = $interval(function() {
setExpirationTime(); setExpirationTime();
}, 1000); }, 1000);
function setExpirationTime() { function setExpirationTime() {
if (moment().isAfter(expirationTime * 1000)) { if (moment().isAfter(expirationTime * 1000)) {
$scope.paymentExpired = true; $scope.paymentExpired = true;
if (countDown) $interval.cancel(countDown); if (self.countDown) $interval.cancel(self.countDown);
} }
$scope.expires = moment(expirationTime * 1000).fromNow(); $scope.expires = moment(expirationTime * 1000).fromNow();
}; };
@ -994,6 +996,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.resetForm = function() { this.resetForm = function() {
this.resetError(); this.resetError();
if (this.countDown) $interval.cancel(this.countDown);
this._paypro = null; this._paypro = null;
this.lockedCurrentFeePerKb = null; this.lockedCurrentFeePerKb = null;
@ -1114,25 +1117,26 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
function _paymentTimeControl(expirationTime) { function _paymentTimeControl(expirationTime) {
self.paymentExpired = false; self.paymentExpired = false;
var countDown;
setExpirationTime(); setExpirationTime();
countDown = $interval(function() {
self.countDown = $interval(function() {
setExpirationTime(); setExpirationTime();
}, 1000); }, 1000);
function setExpirationTime() { function setExpirationTime() {
if (moment().isAfter(expirationTime * 1000)) { if (moment().isAfter(expirationTime * 1000)) {
setExpiredPaymentValues(); setExpiredValues();
if (countDown) $interval.cancel(countDown); return;
} }
self.remainingTimeStr = moment(expirationTime * 1000).fromNow(); self.remainingTimeStr = moment(expirationTime * 1000).fromNow();
}; };
function setExpiredPaymentValues() { function setExpiredValues() {
self.paymentExpired = true; self.paymentExpired = true;
self.remainingTimeStr = null; self.remainingTimeStr = null;
self._paypro = null; self._paypro = null;
self.error = gettext('Cannot sign: The payment request has expired'); self.error = gettext('Cannot sign: The payment request has expired');
if (self.countDown) $interval.cancel(self.countDown);
}; };
}; };