[polari/wip/fmuellner/combined-gsoc: 130/137] userTracker: Remove connectRoomSignals()



commit 26cf3830af6bc6b0e90a13abe3e682fc485f7ad2
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jul 26 23:55:47 2016 +0200

    userTracker: Remove connectRoomSignals()
    
    Splitting out the code doesn't add any clarity over just setting
    up signals in onRoomAdded() ...

 src/userTracker.js |   33 ++++++++++++++-------------------
 1 files changed, 14 insertions(+), 19 deletions(-)
---
diff --git a/src/userTracker.js b/src/userTracker.js
index 3b21bb1..5828506 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -112,26 +112,11 @@ const UserTracker = new Lang.Class({
     },
 
     _onRoomAdded: function(roomManager, room) {
-        if (room.account == this._account)
-            this._connectRoomSignalsForRoom(room);
-    },
-
-    _onRoomRemoved: function(roomManager, room) {
-        if (!this._roomData.has(room))
+        if (room.account != this._account)
             return;
 
-        this._getRoomSignals(room).forEach(id => { room.disconnect(id); });
-        this._clearUsersFromRoom(room);
-        this._roomData.delete(room);
-    },
-
-    },
-
-    _connectRoomSignalsForRoom: function(room) {
         this._ensureRoomMappingForRoom(room);
 
-        let currentRoomSignals = this._getRoomSignals(room);
-
         let roomSignals = [
             { name: 'notify::channel',
               handler: Lang.bind(this, this._onChannelChanged) },
@@ -149,9 +134,19 @@ const UserTracker = new Lang.Class({
               handler: Lang.bind(this, this._onMemberLeft) }
         ];
 
-        roomSignals.forEach(Lang.bind(this, function(signal) {
-            currentRoomSignals.push(room.connect(signal.name, signal.handler));
-        }));
+        let signalIds = this._getRoomSignals(room);
+        roomSignals.forEach(signal => {
+            signalIds.push(room.connect(signal.name, signal.handler));
+        });
+    },
+
+    _onRoomRemoved: function(roomManager, room) {
+        if (!this._roomData.has(room))
+            return;
+
+        this._getRoomSignals(room).forEach(id => { room.disconnect(id); });
+        this._clearUsersFromRoom(room);
+        this._roomData.delete(room);
     },
 
     _onChannelChanged: function(room) {


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