[polari/wip/fmuellner/misc-cleanups: 6/12] accountsMonitor: Mirror ::account-enabled/disabled signals



commit 3d280d8b0cdc009d35ccd59981de8b5affca24c6
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jul 30 17:29:58 2016 +0200

    accountsMonitor: Mirror ::account-enabled/disabled signals
    
    To get notified about accounts being enabled or disabled rather than
    added/removed, we currently use the Tp.AccountManager signals directly.
    That's not terrible, but having the signals on the AccountsMonitor
    instead is a bit more convenient, and means we only get notifications
    about accounts we actually care about (that is, no GTalk/Jabber or
    other non-IRC ones).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769582

 src/accountsMonitor.js |    2 ++
 src/chatroomManager.js |   16 ++++++++--------
 src/roomList.js        |   15 ++++++---------
 3 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index 30dc870..247250a 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -131,6 +131,8 @@ const AccountsMonitor = new Lang.Class({
     _accountEnabledChanged: function(am, account) {
         if (!this._accounts.has(account.object_path))
             return;
+        this.emit(account.enabled ? 'account-enabled'
+                                  : 'account-disabled', account);
         this.emit('accounts-changed');
     }
 });
diff --git a/src/chatroomManager.js b/src/chatroomManager.js
index 8f9479f..24201d1 100644
--- a/src/chatroomManager.js
+++ b/src/chatroomManager.js
@@ -220,12 +220,12 @@ const _ChatroomManager = new Lang.Class({
         if (!ready)
             return;
 
-        am.connect('account-enabled',
-                   Lang.bind(this, this._onAccountEnabled));
-        am.connect('account-disabled',
-                   Lang.bind(this, this._onAccountDisabled));
-        am.connect('account-removed',
-                   Lang.bind(this, this._onAccountDisabled));
+        this._accountsMonitor.connect('account-enabled',
+                                      Lang.bind(this, this._onAccountEnabled));
+        this._accountsMonitor.connect('account-disabled',
+                                      Lang.bind(this, this._onAccountDisabled));
+        this._accountsMonitor.connect('account-removed',
+                                      Lang.bind(this, this._onAccountDisabled));
         this._accountsMonitor.connect('account-status-changed', Lang.bind(this, function(monitor, account) {
             if (account.connection_status == Tp.ConnectionStatus.CONNECTED)
                 this._restoreSavedChannels(account);
@@ -248,11 +248,11 @@ const _ChatroomManager = new Lang.Class({
             }));
     },
 
-    _onAccountEnabled: function(am, account) {
+    _onAccountEnabled: function(mon, account) {
         this._restoreSavedChannels(account);
     },
 
-    _onAccountDisabled: function(am, account) {
+    _onAccountDisabled: function(mon, account) {
         for (let id in this._rooms) {
             let room = this._rooms[id];
             if (room.account == account)
diff --git a/src/roomList.js b/src/roomList.js
index 5fdcf1e..c2cc63d 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -359,20 +359,17 @@ const RoomList = new Lang.Class({
                 let accounts = this._accountsMonitor.accounts;
                 for (let i = 0; i < accounts.length; i++)
                     this._accountAdded(mon, accounts[i]);
-
-                am.connect('account-enabled', Lang.bind(this,
-                    function(am, account) {
-                        this._updatePlaceholderVisibility(account);
-                    }));
-                am.connect('account-disabled', Lang.bind(this,
-                    function(am, account) {
-                        this._updatePlaceholderVisibility(account);
-                    }));
             }));
         this._accountsMonitor.connect('account-added',
                                       Lang.bind(this, this._accountAdded));
         this._accountsMonitor.connect('account-removed',
                                       Lang.bind(this, this._accountRemoved));
+        this._accountsMonitor.connect('account-enabled', (mon, account) => {
+            this._updatePlaceholderVisibility(account);
+        });
+        this._accountsMonitor.connect('account-disabled', (mon, account) => {
+            this._updatePlaceholderVisibility(account);
+        });
 
         this._roomManager = ChatroomManager.getDefault();
         this._roomManager.connect('room-added',


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