refactor
This commit is contained in:
parent
256f7218d7
commit
8d591ab7ab
3 changed files with 24 additions and 16 deletions
|
|
@ -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>{{tx.paypro.expires * 1000 | amTimeAgo }}</time>
|
<time>{{expires * 1000 | amTimeAgo }}</time>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="line-b p10">
|
<li class="line-b p10">
|
||||||
|
|
|
||||||
|
|
@ -365,7 +365,7 @@
|
||||||
ng-click="home.sendAll()"
|
ng-click="home.sendAll()"
|
||||||
translate> Send All
|
translate> Send All
|
||||||
</a>
|
</a>
|
||||||
<div ng-show="!home.paymentExpired">
|
<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.timeToExpire * 1000 | amTimeAgo}}</time>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -477,7 +477,7 @@
|
||||||
<a ng-click="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a>
|
<a ng-click="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 type="submit" class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline || (home.paymentExpired && home.usePaypro)"
|
<button type="submit" class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline || (home.paymentExpired && home._paypro)"
|
||||||
ng-style="{'background-color':index.backgroundColor}" translate>
|
ng-style="{'background-color':index.backgroundColor}" translate>
|
||||||
Send
|
Send
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService) {
|
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService, txService) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
window.ignoreMobilePause = false;
|
window.ignoreMobilePause = false;
|
||||||
|
|
@ -27,8 +27,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
this.showScanner = false;
|
this.showScanner = false;
|
||||||
this.addr = {};
|
this.addr = {};
|
||||||
this.lockedCurrentFeePerKb = null;
|
this.lockedCurrentFeePerKb = null;
|
||||||
this.paymentExpired = true;
|
this.paymentExpired = false;
|
||||||
this.usePaypro = false;
|
|
||||||
|
|
||||||
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) {
|
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) {
|
||||||
self.setForm(data);
|
self.setForm(data);
|
||||||
|
|
@ -285,8 +284,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
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) {
|
||||||
$scope.paymentExpired = false;
|
$scope.paymentExpired = null;
|
||||||
$scope.usePaypro = false;
|
|
||||||
checkPaypro();
|
checkPaypro();
|
||||||
$scope.error = null;
|
$scope.error = null;
|
||||||
$scope.copayers = copayers
|
$scope.copayers = copayers
|
||||||
|
|
@ -295,6 +293,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
$scope.loading = null;
|
$scope.loading = null;
|
||||||
$scope.color = fc.backgroundColor;
|
$scope.color = fc.backgroundColor;
|
||||||
$scope.isShared = fc.credentials.n > 1;
|
$scope.isShared = fc.credentials.n > 1;
|
||||||
|
var now = Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
// ToDo: use tx.customData instead of tx.message
|
// ToDo: use tx.customData instead of tx.message
|
||||||
if (tx.message === 'Glidera transaction' && isGlidera) {
|
if (tx.message === 'Glidera transaction' && isGlidera) {
|
||||||
|
|
@ -311,19 +310,31 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
};
|
};
|
||||||
|
|
||||||
function checkPaypro() {
|
function checkPaypro() {
|
||||||
if(tx.payProUrl && !isChromeApp){
|
if (tx.payProUrl && !isChromeApp) {
|
||||||
fc.fetchPayPro({
|
fc.fetchPayPro({
|
||||||
payProUrl: tx.payProUrl,
|
payProUrl: tx.payProUrl,
|
||||||
}, function(err, paypro) {
|
}, function(err, paypro) {
|
||||||
if (err) return;
|
if (err) return;
|
||||||
tx.paypro = paypro;
|
tx.paypro = paypro;
|
||||||
$scope.usePaypro = true;
|
$scope.paymentExpired = tx.paypro.expires <= now;
|
||||||
$scope.paymentExpired = tx.paypro.expires <= Math.floor(Date.now() / 1000);
|
if (!$scope.paymentExpired)
|
||||||
|
paymentTimeControl(tx.paypro.expires);
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function paymentTimeControl(timeToExpire) {
|
||||||
|
$scope.expires = timeToExpire;
|
||||||
|
var countDown = $interval(function() {
|
||||||
|
if ($scope.expires <= now) {
|
||||||
|
$scope.paymentExpired = true;
|
||||||
|
$interval.cancel(countDown);
|
||||||
|
}
|
||||||
|
$scope.expires --;
|
||||||
|
}, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
lodash.each(['TxProposalRejectedBy', 'TxProposalAcceptedBy', 'transactionProposalRemoved', 'TxProposalRemoved', 'NewOutgoingTx', 'UpdateTx'], function(eventName) {
|
lodash.each(['TxProposalRejectedBy', 'TxProposalAcceptedBy', 'transactionProposalRemoved', 'TxProposalRemoved', 'NewOutgoingTx', 'UpdateTx'], function(eventName) {
|
||||||
$rootScope.$on(eventName, function() {
|
$rootScope.$on(eventName, function() {
|
||||||
fc.getTx($scope.tx.id, function(err, tx) {
|
fc.getTx($scope.tx.id, function(err, tx) {
|
||||||
|
|
@ -970,8 +981,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
|
|
||||||
this.resetForm = function() {
|
this.resetForm = function() {
|
||||||
this.resetError();
|
this.resetError();
|
||||||
this.paymentExpired = true;
|
this.paymentExpired = false;
|
||||||
this.usePaypro = false;
|
|
||||||
this._paypro = null;
|
this._paypro = null;
|
||||||
this.lockedCurrentFeePerKb = null;
|
this.lockedCurrentFeePerKb = null;
|
||||||
|
|
||||||
|
|
@ -1091,7 +1101,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
};
|
};
|
||||||
|
|
||||||
function _paymentTimeControl(timeToExpire) {
|
function _paymentTimeControl(timeToExpire) {
|
||||||
self.usePaypro = true;
|
|
||||||
var now = Math.floor(Date.now() / 1000);
|
var now = Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
if (timeToExpire <= now) {
|
if (timeToExpire <= now) {
|
||||||
|
|
@ -1099,7 +1108,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.paymentExpired = false;
|
|
||||||
self.timeToExpire = timeToExpire;
|
self.timeToExpire = timeToExpire;
|
||||||
var countDown = $interval(function() {
|
var countDown = $interval(function() {
|
||||||
if (self.timeToExpire <= now) {
|
if (self.timeToExpire <= now) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue