[polari/wip/fmuellner/misc-fixes: 4/7] mainWindow: Initialize sidebar visibility



commit 6482e92e20f9c5a2916b15ba743467dff28e59c1
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jul 14 17:54:51 2016 +0200

    mainWindow: Initialize sidebar visibility
    
    The code currently assumes that the window is created before accounts are
    initialized, which is the case in the common case that the application is
    activated immediately. However when started through an action (for example
    when clicking a persistent notification), accounts may already be ready
    when we call activate() ourselves, and the sidebar remains hidden (until
    the user adds another account). Fix this by making sure the visibility
    is properly initialized.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769592

 src/mainWindow.js |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index f8088d9..8114590 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -154,10 +154,9 @@ const MainWindow = new Lang.Class({
             }));
 
         this._accountsMonitor = AccountsMonitor.getDefault();
-        this._accountsMonitor.connect('accounts-changed', () => {
-            let hasAccounts = this._accountsMonitor.enabledAccounts.length > 0;
-            this._roomListRevealer.reveal_child = hasAccounts;
-        });
+        this._accountsMonitor.connect('accounts-changed',
+                                      Lang.bind(this, this._onAccountsChanged));
+        this._onAccountsChanged(this._accountsMonitor);
 
         this._roomManager = ChatroomManager.getDefault();
         this._roomManager.connect('active-changed',
@@ -221,6 +220,11 @@ const MainWindow = new Lang.Class({
                                  GLib.Variant.new('ai', this._currentSize));
     },
 
+    _onAccountsChanged: function(am) {
+        let hasAccounts = this._accountsMonitor.enabledAccounts.length > 0;
+        this._roomListRevealer.reveal_child = hasAccounts;
+    },
+
     _updateDecorations: function() {
         let layoutLeft = null;
         let layoutRight = null;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]