refactor spinners - handle errors
This commit is contained in:
parent
d6c25896f7
commit
eabe2c9407
3 changed files with 56 additions and 65 deletions
|
|
@ -8,13 +8,6 @@
|
|||
<h1 class="title ellipsis" translate>Payment Proposal</h1>
|
||||
</ion-header-bar>
|
||||
|
||||
<div class="onGoingProcess" ng-show="loading">
|
||||
<div class="onGoingProcess-content" ng-style="{'background-color':index.backgroundColor}">
|
||||
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
|
||||
<span>{{loading|translate}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ion-content ng-style="{'background-color': '#F6F7F9'}">
|
||||
<div class="modal-content fix-modals-touch" ng-init="updateCopayerList()">
|
||||
<div class="payment-proposal-head" ng-style="{'background-color':color}">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, profileService, walletService) {
|
||||
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, profileService, walletService) {
|
||||
var self = $scope.self;
|
||||
var tx = $scope.tx;
|
||||
var copayers = $scope.copayers;
|
||||
|
|
@ -25,60 +25,57 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
|
||||
$scope.sign = function(txp) {
|
||||
$scope.error = null;
|
||||
var prefix = fc.credentials.m > 1 ? gettextCatalog.getString('Could not create payment proposal') : gettextCatalog.getString('Could not send payment');
|
||||
$scope.loading = true;
|
||||
|
||||
$scope.loading = 'Signing Transaction';
|
||||
fingerprintService.check(fc, function(err) {
|
||||
if (err) {
|
||||
$scope.loading = null;
|
||||
$scope.error = prefix;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
handleEncryptedWallet(function(err) {
|
||||
$timeout(function() {
|
||||
fingerprintService.check(fc, function(err) {
|
||||
if (err) {
|
||||
$scope.loading = null;
|
||||
$scope.error = bwcError.msg(err, prefix);
|
||||
$scope.error = gettextCatalog.getString('Could not send payment');
|
||||
$scope.loading = false;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
walletService.signTx(fc, txp, function(err, signedTxp) {
|
||||
handleEncryptedWallet(function(err) {
|
||||
if (err) {
|
||||
$scope.loading = null;
|
||||
$scope.error = bwcError.msg(err, prefix);
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 1);
|
||||
return;
|
||||
return setError(err);
|
||||
}
|
||||
|
||||
if (signedTxp.status == 'accepted') {
|
||||
$scope.loading = 'Broadcasting Transaction';
|
||||
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) {
|
||||
$scope.loading = null;
|
||||
ongoingProcess.set('signingTx', true);
|
||||
walletService.signTx(fc, txp, function(err, signedTxp) {
|
||||
ongoingProcess.set('signingTx', false);
|
||||
if (err) {
|
||||
return setError(err);
|
||||
}
|
||||
|
||||
if (signedTxp.status == 'accepted') {
|
||||
ongoingProcess.set('broadcastingTx', true);
|
||||
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) {
|
||||
ongoingProcess.set('broadcastingTx', false);
|
||||
$scope.$emit('UpdateTx');
|
||||
$scope.close(broadcastedTxp);
|
||||
if (err) {
|
||||
return setError(err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$scope.$emit('UpdateTx');
|
||||
$scope.close(broadcastedTxp);
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 1);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$scope.loading = null;
|
||||
$scope.$emit('UpdateTx');
|
||||
$scope.close(signedTxp);
|
||||
}
|
||||
$scope.close(signedTxp);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
|
||||
function setError(err, prefix) {
|
||||
$scope.loading = false;
|
||||
$scope.error = bwcError.msg(err, prefix);
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 10);
|
||||
};
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
|
|
@ -86,57 +83,57 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
});
|
||||
|
||||
$scope.reject = function(txp) {
|
||||
$scope.loading = 'Rejecting payment';
|
||||
$scope.loading = true;
|
||||
$scope.error = null;
|
||||
|
||||
$timeout(function() {
|
||||
ongoingProcess.set('rejectTx', true);
|
||||
walletService.rejectTx(fc, txp, function(err, txpr) {
|
||||
$scope.loading = null;
|
||||
ongoingProcess.set('rejectTx', false);
|
||||
|
||||
if (err) {
|
||||
$scope.$emit('UpdateTx');
|
||||
$scope.error = bwcError.msg(err, gettextCatalog.getString('Could not reject payment'));
|
||||
$scope.$digest();
|
||||
} else {
|
||||
$scope.close(txpr);
|
||||
return setError(err, gettextCatalog.getString('Could not reject payment'));
|
||||
}
|
||||
|
||||
$scope.close(txpr);
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
|
||||
$scope.remove = function(txp) {
|
||||
$scope.loading = 'Deleting Payment';
|
||||
$scope.loading = true;
|
||||
$scope.error = null;
|
||||
|
||||
$timeout(function() {
|
||||
ongoingProcess.set('removeTx', true);
|
||||
walletService.removeTx(fc, txp, function(err) {
|
||||
$scope.loading = null;
|
||||
ongoingProcess.set('removeTx', false);
|
||||
|
||||
// Hacky: request tries to parse an empty response
|
||||
if (err && !(err.message && err.message.match(/Unexpected/))) {
|
||||
$scope.$emit('UpdateTx');
|
||||
$scope.error = bwcError.msg(err, gettextCatalog.getString('Could not delete payment proposal'));
|
||||
$scope.$digest();
|
||||
return;
|
||||
return setError(err, gettextCatalog.getString('Could not delete payment proposal'));
|
||||
}
|
||||
|
||||
$scope.close();
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
|
||||
$scope.broadcast = function(txp) {
|
||||
$scope.loading = 'Broadcasting Payment';
|
||||
$scope.loading = true;
|
||||
$scope.error = null;
|
||||
|
||||
$timeout(function() {
|
||||
ongoingProcess.set('broadcastTx', true);
|
||||
walletService.broadcastTx(fc, txp, function(err, txpb) {
|
||||
$scope.loading = null;
|
||||
ongoingProcess.set('broadcastTx', false);
|
||||
|
||||
if (err) {
|
||||
$scope.error = bwcError.msg(err, gettextCatalog.getString('Could not broadcast payment'));
|
||||
$scope.$digest();
|
||||
return;
|
||||
return setError(err, gettextCatalog.getString('Could not broadcast payment'));
|
||||
}
|
||||
|
||||
$scope.close(txpb);
|
||||
});
|
||||
}, 10);
|
||||
|
|
@ -193,7 +190,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
$scope.tx.canBeRemoved = false;
|
||||
$scope.tx.pendingForUs = false;
|
||||
$scope.$apply();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
|
|||
'sendingTx': gettext('Sending transaction'),
|
||||
'signingTx': gettext('Signing transaction'),
|
||||
'broadcastingTx': gettext('Broadcasting transaction'),
|
||||
'rejectTx': gettext('Rejecting payment proposal'),
|
||||
'removeTx': gettext('Deleting payment proposal'),
|
||||
'fetchingPayPro': gettext('Fetching Payment Information'),
|
||||
'calculatingFee': gettext('Calculating fee'),
|
||||
'joiningWallet': gettext('Joining Wallet...'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue