Skip to content

Commit

Permalink
Fix for password error
Browse files Browse the repository at this point in the history
The old error handler wasn't really working for unknown reasons, but
this seems to fix it.
  • Loading branch information
torhve committed Dec 16, 2015
1 parent 0390d41 commit 68a766a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions js/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ weechat.factory('connection',

// Takes care of the connection and websocket hooks
var connect = function (host, port, passwd, ssl, noCompression, successCallback, failCallback) {
$rootScope.passwordError = false;
connectionData = [host, port, passwd, ssl, noCompression];
var proto = ssl ? 'wss' : 'ws';
// If host is an IPv6 literal wrap it in brackets
Expand Down Expand Up @@ -98,11 +99,8 @@ weechat.factory('connection',
$log.info("Connected to relay");
$rootScope.connected = true;
},
function() {
// Connection got closed, lets check if we ever was connected successfully
if (!$rootScope.waseverconnected) {
$rootScope.passwordError = true;
}
function(e) {
handleWrongPassword();
}
);

Expand All @@ -121,12 +119,14 @@ weechat.factory('connection',
* Handles websocket disconnection
*/
$log.info("Disconnected from relay");
$rootScope.$emit('relayDisconnect');
if ($rootScope.userdisconnect || !$rootScope.waseverconnected) {
handleClose(evt);
$rootScope.userdisconnect = false;
} else {
reconnect(evt);
}
handleWrongPassword();
};

var handleClose = function (evt) {
Expand All @@ -140,6 +140,14 @@ weechat.factory('connection',
}
};

var handleWrongPassword = function() {
// Connection got closed, lets check if we ever was connected successfully
if (!$rootScope.waseverconnected && !$rootScope.errorMessage) {
$rootScope.passwordError = true;
$rootScope.$apply();
}
};

var onerror = function (evt) {
/*
* Handles cases when connection issues come from
Expand Down

0 comments on commit 68a766a

Please sign in to comment.