[polari/wip/fmuellner/combined-gsoc: 64/137] Split out the function that ensures the fact that there is a contact mapping for the specified room



commit 6900a36d2f5ae61a40521d1d22712bf22d253a1b
Author: raresv <rares visalom gmail com>
Date:   Mon Jul 11 02:06:20 2016 +0300

    Split out the function that ensures the fact that there is a contact mapping for the specified room and 
used this fufuncton in UserTracker.getBestMatchContactInRoom(). The reason for this is that any popover 
opened until polari is connected will result in an error (because the mapping was not ensured before).

 src/userTracker.js |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/userTracker.js b/src/userTracker.js
index 0b90e4f..e5fca68 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -151,8 +151,7 @@ const UserTracker = new Lang.Class({
 
             /*if there is no map keeping track of the users in the emittingRoom
             create it*/
-            if (!this._roomMapping.get(emittingRoom)._contactMapping)
-                this._roomMapping.get(emittingRoom)._contactMapping = new Map();
+            this._ensureContactMappingForRoom(emittingRoom);
 
             /*if there is no map keeping track of the local status change handlers*/
             this._ensureHandlerMappingForRoom(emittingRoom);
@@ -195,6 +194,11 @@ const UserTracker = new Lang.Class({
             this._roomMapping.set(room, {});
     },
 
+    _ensureContactMappingForRoom: function(room) {
+        if (!this._roomMapping.get(room)._contactMapping)
+            this._roomMapping.get(room)._contactMapping = new Map();
+    },
+
     _ensureHandlerMappingForRoom: function(room) {
         /*if there is no map keeping track of the local status change handlers*/
         if (!this._roomMapping.get(room)._handlerMapping) {
@@ -312,6 +316,9 @@ const UserTracker = new Lang.Class({
 
     getBestMatchingContactInRoom: function(room, nickName) {
         let baseNick = Polari.util_get_basenick(nickName);
+
+        this._ensureContactMappingForRoom(room);
+
         let contacts = this._roomMapping.get(room)._contactMapping.get(baseNick) || [];
 
         /*TODO: even possible?*/


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