handle the PeerID-already-in-use error and display a friendly message
This commit is contained in:
parent
f4f060a45b
commit
190185ac9c
3 changed files with 17 additions and 3 deletions
|
|
@ -162,10 +162,14 @@
|
||||||
<!-- Templates -->
|
<!-- Templates -->
|
||||||
<script type="text/ng-template" id="signin.html">
|
<script type="text/ng-template" id="signin.html">
|
||||||
<div class="signin" ng-controller="SigninController">
|
<div class="signin" ng-controller="SigninController">
|
||||||
<div data-alert class="alert-box info radius" ng-show="loading">
|
<div data-alert class="alert-box info radius" ng-show="loading && !failure">
|
||||||
<i class="size-21 fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="size-21 fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
Authenticating and Looking for peers...
|
Authenticating and Looking for peers...
|
||||||
</div>
|
</div>
|
||||||
|
<div class="alert-box error radius" ng-show="failure">
|
||||||
|
Oops, we had an error! Looks like you are already connected to this wallet,
|
||||||
|
please close all other Copay Wallets and <a ng-click='failure = false; loading = false'>Try again</a>.
|
||||||
|
</div>
|
||||||
<div ng-show="!loading">
|
<div ng-show="!loading">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-6 medium-6 columns">
|
<div class="large-6 medium-6 columns">
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ angular.module('copay.signin').controller('SigninController',
|
||||||
return v1 > v2 ? 1 : ( v1 < v2 ) ? -1 : 0;
|
return v1 > v2 ? 1 : ( v1 < v2 ) ? -1 : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.loading = false;
|
$scope.loading = $scope.failure = false;
|
||||||
$scope.wallets = walletFactory.getWallets().sort(cmp);
|
$scope.wallets = walletFactory.getWallets().sort(cmp);
|
||||||
$scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null;
|
$scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null;
|
||||||
$scope.openPassword = '';
|
$scope.openPassword = '';
|
||||||
|
|
@ -34,12 +34,13 @@ angular.module('copay.signin').controller('SigninController',
|
||||||
Passphrase.getBase64Async(password, function(passphrase){
|
Passphrase.getBase64Async(password, function(passphrase){
|
||||||
var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase});
|
var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase});
|
||||||
if (!w) {
|
if (!w) {
|
||||||
$scope.loading = false;
|
$scope.loading = $scope.failure = false;
|
||||||
$rootScope.flashMessage = { message: 'Bad password or connection error', type: 'error'};
|
$rootScope.flashMessage = { message: 'Bad password or connection error', type: 'error'};
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controllerUtils.startNetwork(w);
|
controllerUtils.startNetwork(w);
|
||||||
|
listenErrors(w);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -66,8 +67,16 @@ angular.module('copay.signin').controller('SigninController',
|
||||||
controllerUtils.onErrorDigest();
|
controllerUtils.onErrorDigest();
|
||||||
} else {
|
} else {
|
||||||
controllerUtils.startNetwork(w);
|
controllerUtils.startNetwork(w);
|
||||||
|
listenErrors(w);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function listenErrors(wallet) {
|
||||||
|
wallet.network.on('error', function(err) {
|
||||||
|
$scope.failure = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
|
||||||
p.on('error', function(err) {
|
p.on('error', function(err) {
|
||||||
if (!err.message.match(/Could\snot\sconnect\sto peer/)) {
|
if (!err.message.match(/Could\snot\sconnect\sto peer/)) {
|
||||||
console.log('### PEER ERROR:', err);
|
console.log('### PEER ERROR:', err);
|
||||||
|
self.emit('error', err);
|
||||||
}
|
}
|
||||||
self._checkAnyPeer();
|
self._checkAnyPeer();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue