diff --git a/js/controllers/signin.js b/js/controllers/signin.js index 37a600e32..1538cd8a6 100644 --- a/js/controllers/signin.js +++ b/js/controllers/signin.js @@ -67,6 +67,8 @@ angular.module('copay.signin').controller('SigninController', if (err || !w) { if (err === 'joinError') $rootScope.flashMessage = { message: 'Can not find peer'}; + else if (err === 'walletFull') + $rootScope.flashMessage = { message: 'The wallet is full'}; else if (err === 'badSecret') $rootScope.flashMessage = { message: 'Bad secret secret string', type: 'error'}; else diff --git a/js/models/core/WalletFactory.js b/js/models/core/WalletFactory.js index 21deb626f..fc7f0ee77 100644 --- a/js/models/core/WalletFactory.js +++ b/js/models/core/WalletFactory.js @@ -200,8 +200,14 @@ WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphras self.network.cleanUp(); self.network.start(opts, function() { self.network.connectTo(s.pubKey); + + // This is a hack to reconize if the connection was rejected or the peer wasn't there. + var connectedOnce = false; + self.network.on('connected', function(sender, data) { + connectedOnce = true; + }); self.network.on('onlyYou', function(sender, data) { - return cb('joinError'); + return cb(connectedOnce ? 'walletFull' : 'joinError'); }); self.network.on('data', function(sender, data) { if (data.type ==='walletId') { diff --git a/js/models/network/WebRTC.js b/js/models/network/WebRTC.js index 06e230537..41719dd9e 100644 --- a/js/models/network/WebRTC.js +++ b/js/models/network/WebRTC.js @@ -223,6 +223,7 @@ Network.prototype._setupConnectionHandlers = function(dataConn, toCopayerId) { // The connecting peer send hello if(toCopayerId) { + self.emit('connected'); self._sendHello(toCopayerId); self._addConnectedCopayer(toCopayerId); } diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index b7457390a..56f87fc00 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -19,7 +19,7 @@ angular.module('copay.controllerUtils') video.close(); // Clear rootScope for (var i in $rootScope) { - if (i.charAt(0) != '$') { + if (i.charAt(0) != '$' && i != 'flashMessage') { delete $rootScope[i]; } }