Merge pull request #4016 from JDonadio/fix/countdown-paypro-02
Fix remaining time paypro
This commit is contained in:
commit
e3341dca1b
3 changed files with 33 additions and 31 deletions
|
|
@ -54,7 +54,7 @@
|
||||||
<div class="large-6 medium-6 small-6 columns text-right" ng-show="canSign">
|
<div class="large-6 medium-6 small-6 columns text-right" ng-show="canSign">
|
||||||
<button class="button primary round expand" ng-click="sign(tx)"
|
<button class="button primary round expand" ng-click="sign(tx)"
|
||||||
ng-style="{'background-color':color}"
|
ng-style="{'background-color':color}"
|
||||||
ng-disabled="loading || (paymentExpired && usePaypro)">
|
ng-disabled="loading || paymentExpired">
|
||||||
<i class="fi-check"></i>
|
<i class="fi-check"></i>
|
||||||
<span translate>Accept</span>
|
<span translate>Accept</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -149,7 +149,7 @@
|
||||||
<li class="line-b p10" ng-if="!paymentExpired">
|
<li class="line-b p10" ng-if="!paymentExpired">
|
||||||
<span class="text-gray" translate>Expires</span>
|
<span class="text-gray" translate>Expires</span>
|
||||||
<span class="right">
|
<span class="right">
|
||||||
<time>{{expires * 1000 | amTimeAgo }}</time>
|
<time>{{expires}}</time>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="line-b p10">
|
<li class="line-b p10">
|
||||||
|
|
|
||||||
|
|
@ -279,13 +279,13 @@
|
||||||
<a class="text-gray size-12"
|
<a class="text-gray size-12"
|
||||||
ng-show="index.historyShowMore"
|
ng-show="index.historyShowMore"
|
||||||
ng-click="index.showMore()">
|
ng-click="index.showMore()">
|
||||||
<span translate>Show more</span>
|
<span translate>Show more</span>
|
||||||
<span ng-if="!index.isSearching">
|
<span ng-if="!index.isSearching">
|
||||||
({{index.completeHistory.length - index.txHistory.length}})
|
({{index.completeHistory.length - index.txHistory.length}})
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="index.isSearching">
|
<span ng-if="index.isSearching">
|
||||||
({{index.result.length - index.txHistorySearchResults.length}})
|
({{index.result.length - index.txHistorySearchResults.length}})
|
||||||
</span>
|
</span>
|
||||||
<i class="icon-arrow-down4"></i>
|
<i class="icon-arrow-down4"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -394,7 +394,7 @@
|
||||||
</a>
|
</a>
|
||||||
<div ng-show="!home.paymentExpired && home._paypro">
|
<div ng-show="!home.paymentExpired && home._paypro">
|
||||||
<span translate>Payment expires</span>
|
<span translate>Payment expires</span>
|
||||||
<time> {{home.timeToExpire * 1000 | amTimeAgo}}</time>
|
<time> {{home.remainingTimeStr}}</time>
|
||||||
</div>
|
</div>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="camera-icon" ng-show="index.isComplete">
|
<div class="camera-icon" ng-show="index.isComplete">
|
||||||
|
|
|
||||||
|
|
@ -336,23 +336,26 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
}, function(err, paypro) {
|
}, function(err, paypro) {
|
||||||
if (err) return;
|
if (err) return;
|
||||||
tx.paypro = paypro;
|
tx.paypro = paypro;
|
||||||
$scope.paymentExpired = tx.paypro.expires <= now;
|
paymentTimeControl(tx.paypro.expires);
|
||||||
if (!$scope.paymentExpired)
|
|
||||||
paymentTimeControl(tx.paypro.expires);
|
|
||||||
$scope.$apply();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function paymentTimeControl(timeToExpire) {
|
function paymentTimeControl(expirationTime) {
|
||||||
$scope.expires = timeToExpire;
|
$scope.paymentExpired = false;
|
||||||
var countDown = $interval(function() {
|
var countDown;
|
||||||
if ($scope.expires <= now) {
|
setExpirationTime();
|
||||||
$scope.paymentExpired = true;
|
countDown = $interval(function() {
|
||||||
$interval.cancel(countDown);
|
setExpirationTime();
|
||||||
}
|
|
||||||
$scope.expires--;
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
function setExpirationTime() {
|
||||||
|
if (moment().isAfter(expirationTime * 1000)) {
|
||||||
|
$scope.paymentExpired = true;
|
||||||
|
if (countDown) $interval.cancel(countDown);
|
||||||
|
}
|
||||||
|
$scope.expires = moment(expirationTime * 1000).fromNow();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
lodash.each(['TxProposalRejectedBy', 'TxProposalAcceptedBy', 'transactionProposalRemoved', 'TxProposalRemoved', 'NewOutgoingTx', 'UpdateTx'], function(eventName) {
|
lodash.each(['TxProposalRejectedBy', 'TxProposalAcceptedBy', 'transactionProposalRemoved', 'TxProposalRemoved', 'NewOutgoingTx', 'UpdateTx'], function(eventName) {
|
||||||
|
|
@ -1107,26 +1110,25 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
}, 1);
|
}, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
function _paymentTimeControl(timeToExpire) {
|
function _paymentTimeControl(expirationTime) {
|
||||||
var now = Math.floor(Date.now() / 1000);
|
self.paymentExpired = false;
|
||||||
|
var countDown;
|
||||||
if (timeToExpire <= now) {
|
setExpirationTime();
|
||||||
setExpiredPaymentValues();
|
countDown = $interval(function() {
|
||||||
return;
|
setExpirationTime();
|
||||||
}
|
|
||||||
|
|
||||||
self.timeToExpire = timeToExpire;
|
|
||||||
var countDown = $interval(function() {
|
|
||||||
if (self.timeToExpire <= now) {
|
|
||||||
setExpiredPaymentValues();
|
|
||||||
$interval.cancel(countDown);
|
|
||||||
}
|
|
||||||
self.timeToExpire--;
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
function setExpirationTime() {
|
||||||
|
if (moment().isAfter(expirationTime * 1000)) {
|
||||||
|
setExpiredPaymentValues();
|
||||||
|
if (countDown) $interval.cancel(countDown);
|
||||||
|
}
|
||||||
|
self.remainingTimeStr = moment(expirationTime * 1000).fromNow();
|
||||||
|
};
|
||||||
|
|
||||||
function setExpiredPaymentValues() {
|
function setExpiredPaymentValues() {
|
||||||
self.paymentExpired = true;
|
self.paymentExpired = true;
|
||||||
self.timeToExpire = 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');
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue