fix remaining time

This commit is contained in:
Javier 2016-03-22 15:26:16 -03:00
parent 5febc0d704
commit 8d427c5849
2 changed files with 18 additions and 20 deletions

View File

@ -279,13 +279,13 @@
<a class="text-gray size-12"
ng-show="index.historyShowMore"
ng-click="index.showMore()">
<span translate>Show more</span>
<span translate>Show more</span>
<span ng-if="!index.isSearching">
({{index.completeHistory.length - index.txHistory.length}})
</span>
</span>
<span ng-if="index.isSearching">
({{index.result.length - index.txHistorySearchResults.length}})
</span>
</span>
<i class="icon-arrow-down4"></i>
</a>
</div>
@ -394,7 +394,7 @@
</a>
<div ng-show="!home.paymentExpired && home._paypro">
<span translate>Payment expires</span>
<time> {{home.timeToExpire * 1000 | amTimeAgo}}</time>
<time>{{home.remainingTimeStr}}</time>
</div>
</h4>
<div class="camera-icon" ng-show="index.isComplete">

View File

@ -1107,26 +1107,24 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}, 1);
};
function _paymentTimeControl(timeToExpire) {
var now = Math.floor(Date.now() / 1000);
if (timeToExpire <= now) {
setExpiredPaymentValues();
return;
}
self.timeToExpire = timeToExpire;
var countDown = $interval(function() {
if (self.timeToExpire <= now) {
setExpiredPaymentValues();
$interval.cancel(countDown);
}
self.timeToExpire--;
function _paymentTimeControl(expirationTime) {
var countDown;
setEpirationTime();
countDown = $interval(function() {
setEpirationTime();
}, 1000);
function setEpirationTime() {
if (moment().isAfter(expirationTime * 1000)) {
setExpiredPaymentValues();
if (countDown) $interval.cancel(countDown);
}
self.remainingTimeStr = moment(expirationTime * 1000).fromNow();
};
function setExpiredPaymentValues() {
self.paymentExpired = true;
self.timeToExpire = null;
self.remainingTimeStr = null;
self._paypro = null;
self.error = gettext('Cannot sign: The payment request has expired');
};