Fix connection accordion again

Slightly different order of things caused #1001 to resurface.
This commit is contained in:
Gina Häußge 2017-06-29 16:44:36 +02:00
parent b205e84d4b
commit 38a5da1c35
2 changed files with 8 additions and 11 deletions

View file

@ -629,7 +629,8 @@ $(function() {
});
}
viewModel._unbound = viewModel._bindings != undefined && viewModel._bindings.length == 0;
viewModel._unbound = viewModel._bindings !== undefined && viewModel._bindings.length === 0;
viewModel._bound = viewModel._bindings.length > 0;
if (viewModel.hasOwnProperty("onAfterBinding")) {
viewModel.onAfterBinding();

View file

@ -81,6 +81,8 @@ $(function() {
};
self.openOrCloseOnStateChange = function() {
if (self._bound !== true) return;
var connectionTab = $("#connection");
if (self.isOperational() && connectionTab.hasClass("in")) {
connectionTab.collapse("hide");
@ -100,7 +102,7 @@ $(function() {
self.isReady(data.flags.ready);
self.isLoading(data.flags.loading);
if (self.loginState.isUser() && self.previousIsOperational != self.isOperational()) {
if (self.loginState.isUser() && self.previousIsOperational !== self.isOperational()) {
// only open or close if the panel is visible (for admins) and
// the state just changed to avoid thwarting manual open/close
self.openOrCloseOnStateChange();
@ -132,16 +134,10 @@ $(function() {
self.onStartup = function() {
self.requestData();
};
// when isAdmin becomes true the first time, set the panel open or
// closed based on the connection state
var subscription = self.loginState.isAdmin.subscribe(function(newValue) {
if (newValue) {
// wait until after the isAdmin state has run through all subscriptions
setTimeout(self.openOrCloseOnStateChange, 0);
subscription.dispose();
}
});
self.onAfterBinding = function() {
self.openOrCloseOnStateChange();
};
}