[polari/wip/fmuellner/combined-gsoc: 63/136] notifyButton is updated in relation with the global status as well. Plus some cleaning up



commit 42ff47ce1621b29f9e0f2bdc2335d37ae74fbd6c
Author: raresv <rares visalom gmail com>
Date:   Mon Jul 11 01:26:38 2016 +0300

    notifyButton is updated in relation with the global status as well. Plus some cleaning up

 src/chatView.js    |    2 --
 src/userList.js    |   36 ++++++++++++++++++++++++------------
 src/userTracker.js |   19 ++++++-------------
 3 files changed, 30 insertions(+), 27 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 1a3026c..2d8e882 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -1267,8 +1267,6 @@ const ChatView = new Lang.Class({
     },*/
 
     _onStatusChangedCallback: function(nick, status) {
-        log("Nick " + nick + " has local status " + status);
-
         let nickTagName = this._getNickTagName(nick);
         let nickTag = this._lookupTag(nickTagName);
 
diff --git a/src/userList.js b/src/userList.js
index 2bd8dc4..a843d57 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -402,35 +402,47 @@ const UserPopover = new Lang.Class({
             this._userTracker.addToWatchlist(this._nickname, this._room.account.get_display_name());
             this._updateNotifyButton();
         }
+        else {
+            this._userTracker.popUserFromWatchlist(this._nickname, this._room.account.get_display_name());
+            this._updateNotifyButton();
+        }
     },
 
     _updateNotifyButton: function() {
+        let isUserGloballyOnline = this._userTracker.getNickStatus(this._nickname) == 
Tp.ConnectionPresenceType.AVAILABLE ? true : false;
+
+        /*TODO: too many conditionals*/
         if (!this._userTracker.isUserWatched(this._nickname, this._room.account.get_display_name()))
-            if (this._user) {
+            if (this._userTracker.getBestMatchingContactInRoom(this._room, this._nickname)) {
                 this._notifyButton.visible = false;
-                //this._notifyButton.sensitive = true;
-                this._notifyButton.set_active(true);
+                this._notifyButton.set_active(false);
             }
             else {
-                this._notifyButton.visible = true;
-                //this._notifyButton.sensitive = true;
-                this._notifyButton.set_active(true);
+                //this._notifyButton.visible = true;
+                if (isUserGloballyOnline)
+                    this._notifyButton.visible = false;
+                else
+                    this._notifyButton.visible = true;
+
+                this._notifyButton.set_active(false);
             }
         else
-            if (this._user) {
+            if (this._userTracker.getBestMatchingContactInRoom(this._room, this._nickname)) {
                 this._notifyButton.visible = false;
-                //this._notifyButton.sensitive = true;
                 this._notifyButton.set_active(true);
             }
             else {
-                this._notifyButton.visibile = true;
-                //this._notifyButton.sensitive = false;
-                this._notifyButton.set_active(false);
+                //this._notifyButton.visibile = true;
+                if (isUserGloballyOnline)
+                    this._notifyButton.visible = false;
+                else
+                    this._notifyButton.visibile = true;
+
+                this._notifyButton.set_active(true);
             }
     },
 
     _onNickStatusChanged: function(nickName, status) {
-        //this.user = this._userTracker.getBestMatchingContact(this._nickname);
         this._updateContents();
     }
 });
diff --git a/src/userTracker.js b/src/userTracker.js
index 0c6f6d2..0b90e4f 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -146,7 +146,7 @@ const UserTracker = new Lang.Class({
             else
                 members = [emittingRoom.channel.connection.self_contact, 
emittingRoom.channel.target_contact];
 
-            /*is this needed here?*/
+            /*TODO: is this needed here?*/
             this._ensureRoomMappingForRoom(emittingRoom);
 
             /*if there is no map keeping track of the users in the emittingRoom
@@ -263,14 +263,10 @@ const UserTracker = new Lang.Class({
         else
             map.set(baseNick, [member]);
 
-        //was on HEAD
-        /*if (this._contactMapping.get(baseNick).length == 1)
-            this.emit("status-changed::"+baseNick, member.alias, Tp.ConnectionPresenceType.AVAILABLE);*/
-
         if (map.get(baseNick).length == 1)
             if (map == this._globalContactMapping) {
                 this.emit("status-changed::" + baseNick, member.alias, Tp.ConnectionPresenceType.AVAILABLE);
-                log("[global status] user " + member.alias + " is globally online");
+                //log("[global status] user " + member.alias + " is globally online");
             }
             else
                 //log("[Local UserTracker] User " + member.alias + " is now available in room " + 
member._room.channelName + " on " + this._account.get_display_name());
@@ -292,11 +288,9 @@ const UserTracker = new Lang.Class({
             let removedMember = contacts.splice(indexToDelete, 1)[0];
 
             if (contacts.length == 0)
-                //was on HEAD
-                /*this.emit("status-changed::"+baseNick, member.alias, Tp.ConnectionPresenceType.OFFLINE);*/
                 if (map == this._globalContactMapping) {
                     this.emit("status-changed::" + baseNick, member.alias, 
Tp.ConnectionPresenceType.OFFLINE);
-                    log("[global status] user " + member.alias + " is globally offline");
+                    //log("[global status] user " + member.alias + " is globally offline");
                 }
                 else
                     //log("[Local UserTracker] User " + member.alias + " is now offline in room " + 
member._room.channelName + " on " + this._account.get_display_name());
@@ -318,10 +312,9 @@ const UserTracker = new Lang.Class({
 
     getBestMatchingContactInRoom: function(room, nickName) {
         let baseNick = Polari.util_get_basenick(nickName);
-        //let contacts = this._globalContactMapping.get(baseNick) || [];
         let contacts = this._roomMapping.get(room)._contactMapping.get(baseNick) || [];
 
-        /*even possible?*/
+        /*TODO: even possible?*/
         if (contacts.length == 0)
             return null;
 
@@ -355,9 +348,9 @@ const UserTracker = new Lang.Class({
     },
 
     unwatchUser: function(room, nick, handlerID) {
-        /*it wouldn't make sense to call _ensure() here, right?*/
+        /*TODO: it wouldn't make sense to call _ensure() here, right?*/
 
-        /*rewrite into a single conditional?*/
+        /*TODO: rewrite into a single conditional?*/
         if (!this._roomMapping)
             return;
 


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