[polari/wip/fmuellner/combined-gsoc: 132/136] userTracker: Remove some roomData helpers



commit 2874005f662ece57b912f757f56c3f64ef7adb4c
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jul 26 23:57:24 2016 +0200

    userTracker: Remove some roomData helpers
    
    getRoomContacts(), getRoomHandlers() and getRoomSignals() hide the
    nested maps in roomData, which helps making the code more readable.
    However wrapping the Map() API for roomData itself only hides that
    roomData is a map, which doesn't seem useful.

 src/userTracker.js |   31 ++++++++-----------------------
 1 files changed, 8 insertions(+), 23 deletions(-)
---
diff --git a/src/userTracker.js b/src/userTracker.js
index 5828506..2901a13 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -93,24 +93,6 @@ const UserTracker = new Lang.Class({
         return this._roomData.get(room)._roomSignals;
     },
 
-    _insertRoomData: function(room, data) {
-        this._roomData.set(room, data);
-    },
-
-    _deleteRoomDataHandler: function(room, handlerID) {
-        if (!this._isRoomData(room))
-            return;
-
-        if (!this._getRoomHandlers(room))
-            return;
-
-        this._getRoomHandlers(room).delete(handlerID);
-    },
-
-    _isRoomData: function(room) {
-        return this._roomData.has(room);
-    },
-
     _onRoomAdded: function(roomManager, room) {
         if (room.account != this._account)
             return;
@@ -175,10 +157,11 @@ const UserTracker = new Lang.Class({
     },
 
     _ensureRoomMappingForRoom: function(room) {
-        if (!this._isRoomData(room))
-            this._insertRoomData(room, { _contactMapping: new Map(),
-                                         _handlerMapping: new Map(),
-                                         _roomSignals: [] });
+        if (this._roomData.has(room))
+            return;
+        this._roomData.set(room, { _contactMapping: new Map(),
+                                   _handlerMapping: new Map(),
+                                   _roomSignals: [] });
     },
 
     _onMemberRenamed: function(room, oldMember, newMember) {
@@ -304,7 +287,9 @@ const UserTracker = new Lang.Class({
     },
 
     unwatchRoomStatus: function(room, handlerID) {
-        this._deleteRoomDataHandler(room, handlerID);
+        if (!this._roomData.has(room))
+            return;
+        this._getRoomHandlers(room).delete(handlerID);
     },
 
     _emitNotification: function (room, member) {


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