New feature: Automatically connect

Check if user saved password, and then offer to automatically connect.
Use a angular watch on the autoconnect and connect as soon as user
selects it.

Check for error messages so it doesn't try to reconnect if there is
errors.
This commit is contained in:
Tor Hveem 2014-07-20 14:32:53 +02:00
parent 95c9969e71
commit 065d8a240d
2 changed files with 16 additions and 0 deletions

View file

@ -77,6 +77,12 @@
Save password in your browser
</label>
</div>
<div class="checkbox" ng-show="savepassword">
<label class="control-label" for="autoconnect">
<input type="checkbox" id="autoconnect" ng-model="autoconnect">
Automatically connect
</label>
</div>
<div class="checkbox">
<label class="control-label" for="ssl">
<input type="checkbox" id="ssl" ng-model="ssl">

View file

@ -829,6 +829,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
if ($scope.savepassword) {
$store.bind($scope, "password", "");
}
$store.bind($scope, "autoconnect", false);
// If we are on mobile change some defaults
// We use 968 px as the cutoff, which should match the value in glowingbear.css
@ -885,6 +886,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
document.getElementById('sidebar').setAttribute('data-state', 'hidden');
document.getElementById('content').setAttribute('sidebar-state', 'hidden');
};
$scope.$watch('autoconnect', function() {
if ($scope.autoconnect && !$rootScope.connected) {
$scope.connect();
}
});
// toggle sidebar (if on mobile)
$scope.toggleSidebar = function() {
@ -1230,6 +1236,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.favico.reset();
};
if ($scope.autoconnect && !$rootScope.connected && !$rootScope.sslError && !$rootScope.securityError && !$rootScope.errorMessage) {
$scope.connect();
}
}]
);