Merge pull request #4648 from JDonadio/bug/cancel-fingerprint-signing

Fix displaying errors in transaction proposal details
This commit is contained in:
Javier Donadío 2016-08-05 15:27:15 -03:00 committed by GitHub
commit b432ce0fc1
3 changed files with 44 additions and 40 deletions

View file

@ -8,13 +8,6 @@
<h1 class="title ellipsis" translate>Payment Proposal</h1> <h1 class="title ellipsis" translate>Payment Proposal</h1>
</ion-header-bar> </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'}"> <ion-content ng-style="{'background-color': '#F6F7F9'}">
<div class="modal-content fix-modals-touch" ng-init="updateCopayerList()"> <div class="modal-content fix-modals-touch" ng-init="updateCopayerList()">
<div class="payment-proposal-head" ng-style="{'background-color':color}"> <div class="payment-proposal-head" ng-style="{'background-color':color}">

View file

@ -1,6 +1,6 @@
'use strict'; '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 self = $scope.self;
var tx = $scope.tx; var tx = $scope.tx;
var copayers = $scope.copayers; var copayers = $scope.copayers;
@ -25,44 +25,42 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.sign = function(txp) { $scope.sign = function(txp) {
$scope.error = null; $scope.error = null;
$scope.loading = 'Signing Transaction'; $scope.loading = true;
$timeout(function() { $timeout(function() {
fingerprintService.check(fc, function(err) { fingerprintService.check(fc, function(err) {
if (err) { if (err) {
$scope.error = bwcError.msg(err); $scope.error = gettextCatalog.getString('Could not send payment');
$scope.loading = null; $scope.loading = false;
$timeout(function() {
$scope.$digest();
}, 1);
return; return;
} }
handleEncryptedWallet(function(err) { handleEncryptedWallet(function(err) {
if (err) { if (err) {
$scope.error = bwcError.msg(err); return setError(err);
$scope.loading = null;
return;
} }
ongoingProcess.set('signingTx', true);
walletService.signTx(fc, txp, function(err, signedTxp) { walletService.signTx(fc, txp, function(err, signedTxp) {
walletService.lock(fc); ongoingProcess.set('signingTx', false);
if (err) { if (err) {
$scope.error = bwcError.msg(err); return setError(err);
$scope.loading = null;
return;
} }
if (signedTxp.status == 'accepted') { if (signedTxp.status == 'accepted') {
$scope.loading = 'Broadcasting Transaction'; ongoingProcess.set('broadcastingTx', true);
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) { walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) {
$scope.loading = null; ongoingProcess.set('broadcastingTx', false);
$scope.$emit('UpdateTx'); $scope.$emit('UpdateTx');
$scope.close(broadcastedTxp); $scope.close(broadcastedTxp);
if (err) { if (err) {
$scope.error = err; return setError(err);
} }
}); });
} else { } else {
$scope.loading = null;
$scope.$emit('UpdateTx'); $scope.$emit('UpdateTx');
$scope.close(signedTxp); $scope.close(signedTxp);
} }
@ -72,58 +70,70 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
}, 10); }, 10);
}; };
function setError(err, prefix) {
$scope.loading = false;
$scope.error = bwcError.msg(err, prefix);
$timeout(function() {
$scope.$digest();
}, 10);
};
$scope.$on('$destroy', function() {
walletService.lock(fc);
});
$scope.reject = function(txp) { $scope.reject = function(txp) {
$scope.loading = 'Rejecting payment'; $scope.loading = true;
$scope.error = null; $scope.error = null;
$timeout(function() { $timeout(function() {
ongoingProcess.set('rejectTx', true);
walletService.rejectTx(fc, txp, function(err, txpr) { walletService.rejectTx(fc, txp, function(err, txpr) {
$scope.loading = null; ongoingProcess.set('rejectTx', false);
if (err) { if (err) {
$scope.$emit('UpdateTx'); $scope.$emit('UpdateTx');
$scope.error = bwcError.msg(err, gettextCatalog.getString('Could not reject payment')); return setError(err, gettextCatalog.getString('Could not reject payment'));
$scope.$digest();
} else {
$scope.close(txpr);
} }
$scope.close(txpr);
}); });
}, 10); }, 10);
}; };
$scope.remove = function(txp) { $scope.remove = function(txp) {
$scope.loading = 'Deleting Payment'; $scope.loading = true;
$scope.error = null; $scope.error = null;
$timeout(function() { $timeout(function() {
ongoingProcess.set('removeTx', true);
walletService.removeTx(fc, txp, function(err) { walletService.removeTx(fc, txp, function(err) {
$scope.loading = null; ongoingProcess.set('removeTx', false);
// Hacky: request tries to parse an empty response // Hacky: request tries to parse an empty response
if (err && !(err.message && err.message.match(/Unexpected/))) { if (err && !(err.message && err.message.match(/Unexpected/))) {
$scope.$emit('UpdateTx'); $scope.$emit('UpdateTx');
$scope.error = bwcError.msg(err, gettextCatalog.getString('Could not delete payment proposal')); return setError(err, gettextCatalog.getString('Could not delete payment proposal'));
$scope.$digest();
return;
} }
$scope.close(); $scope.close();
}); });
}, 10); }, 10);
}; };
$scope.broadcast = function(txp) { $scope.broadcast = function(txp) {
$scope.loading = 'Broadcasting Payment'; $scope.loading = true;
$scope.error = null; $scope.error = null;
$timeout(function() { $timeout(function() {
ongoingProcess.set('broadcastTx', true);
walletService.broadcastTx(fc, txp, function(err, txpb) { walletService.broadcastTx(fc, txp, function(err, txpb) {
$scope.loading = null; ongoingProcess.set('broadcastTx', false);
if (err) { if (err) {
$scope.error = bwcError.msg(err, gettextCatalog.getString('Could not broadcast payment')); return setError(err, gettextCatalog.getString('Could not broadcast payment'));
$scope.$digest();
return;
} }
$scope.close(txpb); $scope.close(txpb);
}); });
}, 10); }, 10);
@ -180,7 +190,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.tx.canBeRemoved = false; $scope.tx.canBeRemoved = false;
$scope.tx.pendingForUs = false; $scope.tx.pendingForUs = false;
$scope.$apply(); $scope.$apply();
return;
} }
return; return;
} }

View file

@ -14,6 +14,8 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
'sendingTx': gettext('Sending transaction'), 'sendingTx': gettext('Sending transaction'),
'signingTx': gettext('Signing transaction'), 'signingTx': gettext('Signing transaction'),
'broadcastingTx': gettext('Broadcasting transaction'), 'broadcastingTx': gettext('Broadcasting transaction'),
'rejectTx': gettext('Rejecting payment proposal'),
'removeTx': gettext('Deleting payment proposal'),
'fetchingPayPro': gettext('Fetching Payment Information'), 'fetchingPayPro': gettext('Fetching Payment Information'),
'calculatingFee': gettext('Calculating fee'), 'calculatingFee': gettext('Calculating fee'),
'joiningWallet': gettext('Joining Wallet...'), 'joiningWallet': gettext('Joining Wallet...'),