Merge pull request #2789 from matiu/bug/connerror2

Bug/connerror2
This commit is contained in:
Gustavo Maximiliano Cortez 2015-05-29 14:52:32 -03:00
commit 497bcf1dc7
5 changed files with 51 additions and 20 deletions

View file

@ -17,7 +17,7 @@
"ng-lodash": "~0.2.0",
"angular-moment": "~0.10.1",
"moment": "~2.10.3",
"angular-bitcore-wallet-client": "^0.0.23",
"angular-bitcore-wallet-client": "^0.0.24",
"angular-ui-router": "~0.2.13",
"qrcode-decoder-js": "*",
"fastclick": "*",

View file

@ -214,6 +214,14 @@
<div class="large-12 columns">
<h2 class="text-center m10t" translate>My Bitcoin address</h2>
<div >
<div class="box-notification" ng-show="home.addrError">
<span class="text-warning">
{{home.addrError|translate}}
</span>
</div>
<div class="text-center" ng-click="home.copyAddress(home.addr)">
<qrcode size="220" data="bitcoin:{{home.addr}}"></qrcode>
<div ng-show="home.generatingAddress" style="position:relative; top:-226px; height:0px">

View file

@ -185,12 +185,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$timeout(function() {
self.setOngoingProcess('updatingStatus', true);
$log.debug('Updating Status:', fc);
$log.debug('Updating Status:', fc, tries);
get(function(err, walletStatus) {
if (!err && untilItChanges && initBalance == walletStatus.balance.totalAmount && tries < 10) {
if (!err && untilItChanges && initBalance == walletStatus.balance.totalAmount && tries < 7) {
return $timeout(function() {
return self.updateAll(null, true, initBalance, ++tries);
}, 1000);
}, 1400 * tries);
}
self.setOngoingProcess('updatingStatus', false);
if (err) {
@ -677,7 +677,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
go.walletHome();
} else if (err && err.cors == 'rejected') {
$log.debug('CORS error:', err);
} else if (err.code === 'ETIMEDOUT') {
} else if (err.code === 'ETIMEDOUT' || err.code === 'CONNERROR') {
$log.debug('Time out:', err);
} else {
var msg = 'Error at Wallet Service: ';
@ -709,7 +709,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}, 5000);
});
lodash.each(['NewOutgoingTx', 'NewTxProposal', 'TxProposalFinallyRejected', 'TxProposalRemoved',
$rootScope.$on('NewOutgoingTx', function() {
self.updateAll(null, true);
});
lodash.each(['NewTxProposal', 'TxProposalFinallyRejected', 'TxProposalRemoved',
'Local/NewTxProposal', 'Local/TxProposalAction', 'ScanFinished'
], function(eventName) {
$rootScope.$on(eventName, function(event, untilItChanges) {

View file

@ -91,9 +91,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var parseError = function(err) {
if (err.message) {
// TODO : this is not used anymore?
if (err.message.indexOf('CORS') >= 0) {
err.message = gettext('Could not connect wallet service. Check your Internet connexion and your wallet service configuration.');
}
if (err.message.indexOf('TIMEDOUT') >= 0) {
err.message = gettext('Wallet service timed out. Check your Internet connexion and your wallet service configuration.');
}
@ -200,7 +202,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
if (err) {
$scope.loading = false;
parseError(err);
$scope.error = err.message || gettext('Could not sign transaction. Please try again.');
$scope.error = err.message || gettext('Could not accept payment. Check you connection and try again');
$scope.$digest();
} else {
//if txp has required signatures then broadcast it
@ -213,12 +215,16 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.loading = false;
if (err) {
parseError(err);
$scope.error = gettext('Could not broadcast transaction. Please try again.');
$scope.error = gettext('Could not broadcast payment. Check you connection and try again');
$scope.$digest();
} else {
console.log('[walletHome.js.219]'); //TODO
if (memo)
$log.info(memo);
$modalInstance.close(txpsb, true);
txpsb.refreshUntilItChanges = true;
$modalInstance.close(txpsb);
}
});
} else {
@ -240,7 +246,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.loading = false;
if (err) {
parseError(err);
$scope.error = err.message || gettext('Could not reject transaction. Please try again.');
$scope.error = err.message || gettext('Could not reject payment. Check you connection and try again');
$scope.$digest();
} else {
$modalInstance.close(txpr);
@ -262,7 +268,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
// Hacky: request tries to parse an empty response
if (err && !(err.message && err.message.match(/Unexpected/))) {
parseError(err);
$scope.error = err.message || gettext('Could not delete transaction. Please try again.');
$scope.error = err.message || gettext('Could not delete payment proposal. Check you connection and try again');
$scope.$digest();
return;
}
@ -281,13 +287,15 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.loading = false;
if (err) {
parseError(err);
$scope.error = err.message || gettext('Could not send transaction. Please try again.');
$scope.error = err.message || gettext('Could not broadcast payment. Check you connection and try again');
$scope.$digest();
} else {
if (memo)
$log.info(memo);
$modalInstance.close(txpb, true);
txpb.refreshUntilItChanges = true;
$modalInstance.close(txpb);
}
});
}, 100);
@ -314,7 +322,9 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
m.addClass('slideOutRight');
});
modalInstance.result.then(function(txp, refreshUntilItChanges) {
modalInstance.result.then(function(txp) {
var refreshUntilItChanges = txp.refreshUntilItChanges;
console.log('[walletHome.js.323:refreshUntilItChanges:]', refreshUntilItChanges); //TODO
self.setOngoingProcess();
if (txp) {
txStatus.notify(txp, function() {
@ -333,21 +343,24 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.setNewAddress = function() {
var fc = profileService.focusedClient;
self.generatingAddress = true;
self.addrError = null;
fc.createAddress(function(err, addr) {
self.generatingAddress = false;
if (err) {
if (err.error.match(/locked/gi)) {
if (err.error && err.error.match(/locked/gi)) {
$log.debug(err.error);
$timeout(function() {
self.setNewAddress();
}, 5000);
} else {
$log.debug('Creating address ERROR:', err);
$scope.$emit('Local/ClientError', err);
parseError(err);
self.addrError = err.message || gettext('Could not create address. Check you connection and try again');
$scope.$digest();
}
return;
}
self.addrError = null;
self.addr = addr.address;
storageService.storeLastAddress(fc.credentials.walletId, addr.address, function() {
@ -358,6 +371,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
};
this.setAddress = function() {
self.addrError = null;
if (self.addr)
return;
@ -527,9 +542,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var fc = profileService.focusedClient;
$log.warn(err);
parseError(err);
var errMessage = 'The transaction' + (fc.credentials.m > 1 ? ' proposal' : '') +
var errMessage =
fc.credentials.m > 1 ? gettext('Could not create payment proposal') : gettext('Could not send payment');
' could not be created: ' + (err.message ? err.message : err);
errMessage = errMessage + '. ' + (err.message ? err.message : gettext('Check you connection and try again'));
this.error = errMessage;

View file

@ -15,6 +15,10 @@ angular.module('copayApp.services')
};
root.storeLast = function(notificationData, walletId) {
if (notificationData.type == 'NewAddress')
return;
lastNotificationOnWallet[walletId] = {
creatorId: notificationData.creatorId,
type: notificationData.type,
@ -38,7 +42,6 @@ angular.module('copayApp.services')
&& notificationData.type === 'TxProposalFinallyRejected')
return true;
return false;
};
@ -73,7 +76,7 @@ angular.module('copayApp.services')
name, {color: color} );
break;
case 'NewOutgoingTx':
notification.sent(gettext('Payment Proposal Sent'),
notification.sent(gettext('Payment Sent'),
name, {color: color} );
break;
case 'NewIncomingTx':