Merge pull request #2060 from matiu/bug/payment-intent
Bug/payment intent
This commit is contained in:
commit
c2598b2646
39 changed files with 935 additions and 888 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('go', function($window, $location) {
|
||||
angular.module('copayApp.services').factory('go', function($window, $rootScope, $location) {
|
||||
var root = {};
|
||||
|
||||
var hideSidebars = function() {
|
||||
|
|
@ -44,7 +44,7 @@ angular.module('copayApp.services').factory('go', function($window, $location) {
|
|||
var ref = window.open(url, '_blank', 'location=no');
|
||||
};
|
||||
|
||||
root.go = function(path) {
|
||||
root.path = function(path) {
|
||||
var parts = path.split('#');
|
||||
$location.path(parts[0]);
|
||||
if (parts[1])
|
||||
|
|
@ -56,5 +56,33 @@ angular.module('copayApp.services').factory('go', function($window, $location) {
|
|||
toggleSidebar(invert);
|
||||
};
|
||||
|
||||
root.walletHome = function() {
|
||||
var w = $rootScope.wallet;
|
||||
preconditions.checkState(w);
|
||||
$rootScope.starting = false;
|
||||
|
||||
if (!w.isComplete()) {
|
||||
root.path('copayers');
|
||||
} else {
|
||||
if ($rootScope.pendingPayment) {
|
||||
root.path('selectWalletForPayment');
|
||||
} else {
|
||||
root.path('homeWallet');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
root.home = function() {
|
||||
if ($rootScope.iden)
|
||||
root.walletHome();
|
||||
else
|
||||
root.path('/');
|
||||
};
|
||||
|
||||
|
||||
root.send = function() {
|
||||
$location.path('send');
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,23 +27,6 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
// TODO should be on 'walletService' or 'go'
|
||||
root.goWalletHome = function() {
|
||||
var w = $rootScope.wallet;
|
||||
if (w) {
|
||||
$rootScope.starting = false;
|
||||
if (!w.isComplete()) {
|
||||
go.go('copayers');
|
||||
} else {
|
||||
if ($rootScope.pendingPayment) {
|
||||
go.go('paymentIntent');
|
||||
} else {
|
||||
go.go('homeWallet');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
root.create = function(email, password, cb) {
|
||||
copay.Identity.create({
|
||||
email: email,
|
||||
|
|
@ -133,10 +116,6 @@ angular.module('copayApp.services')
|
|||
$rootScope.iden = iden;
|
||||
};
|
||||
|
||||
root.setPaymentWallet = function(w) {
|
||||
root.setFocusedWallet(w);
|
||||
$location.path('/send');
|
||||
};
|
||||
|
||||
root.noFocusedWallet = function() {
|
||||
$rootScope.wallet = null;
|
||||
|
|
@ -296,7 +275,7 @@ angular.module('copayApp.services')
|
|||
if (wid == iden.getLastFocusedWalletId()) {
|
||||
copay.logger.debug('GOT Focused wallet:', w.getName());
|
||||
root.setFocusedWallet(w, true);
|
||||
root.goWalletHome();
|
||||
go.walletHome();
|
||||
}
|
||||
|
||||
// At the end (after all handlers are in place)...start the wallet.
|
||||
|
|
|
|||
39
js/services/txStatus.js
Normal file
39
js/services/txStatus.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('txStatus', function($modal) {
|
||||
var root = {};
|
||||
|
||||
root.notify = function(status) {
|
||||
var msg;
|
||||
if (status == copay.Wallet.TX_BROADCASTED)
|
||||
msg = 'Transaction broadcasted!';
|
||||
else if (status == copay.Wallet.TX_PROPOSAL_SENT)
|
||||
msg = 'Transaction proposal created';
|
||||
else if (status == copay.Wallet.TX_SIGNED)
|
||||
msg = 'Transaction proposal was signed';
|
||||
else if (status == copay.Wallet.TX_SIGNED_AND_BROADCASTED)
|
||||
msg = 'Transaction signed and broadcasted!';
|
||||
else if (status == 'txRejected')
|
||||
msg = 'Transaction was rejected!';
|
||||
|
||||
if (msg)
|
||||
root.openModal(msg);
|
||||
return msg ? true : false;
|
||||
};
|
||||
|
||||
root.openModal = function(statusStr) {
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
$scope.statusStr = statusStr;
|
||||
$scope.cancel = function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
};
|
||||
$modal.open({
|
||||
templateUrl: 'views/modals/tx-status.html',
|
||||
windowClass: 'tiny',
|
||||
controller: ModalInstanceCtrl,
|
||||
});
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue