[polari/wip/fmuellner/3-24-1-candidates: 3/10] userTracker: Improve status tracking for private chats



commit 3d92ca51827e43f799ac4725037ffdb519b2dc23
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Oct 6 02:39:31 2016 +0200

    userTracker: Improve status tracking for private chats
    
    The ::group-contacts-changed signal is limited to channels implementing
    the group interface, so we miss when the remote contact disconnects from
    a private chat. Work around this by ignoring contacts from one-to-one
    chats for the global status, and remove contacts from all rooms when their
    global status becomes OFFLINE.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712635

 src/userTracker.js |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/src/userTracker.js b/src/userTracker.js
index b484ee4..bc97b19 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -205,14 +205,20 @@ const UserTracker = new Lang.Class({
         if (this._pushMember(roomMap, baseNick, member) == 1)
             this._runHandlers(room, member, status);
 
-        let map = this._baseNickContacts;
-        if (this._pushMember(map, baseNick, member) == 1) {
-            this.emit("status-changed::" + baseNick, baseNick, status);
-
-            if (this._shouldNotifyNick(member.alias))
-                this._notifyNickAvailable(member, room);
-
-            this._setNotifyActionEnabled(member.alias, false);
+        // HACK: Telepathy doesn't notify on member changes for private chats,
+        //       so approximate the online status in this case by not adding
+        //       the contact to the global map, and removing it from the room
+        //       map when the global count drops to 0 (see _untrackMember)
+        if (room.type == Tp.HandleType.ROOM) {
+            let map = this._baseNickContacts;
+            if (this._pushMember(map, baseNick, member) == 1) {
+                this.emit("status-changed::" + baseNick, baseNick, status);
+
+                if (this._shouldNotifyNick(member.alias))
+                    this._notifyNickAvailable(member, room);
+
+                this._setNotifyActionEnabled(member.alias, false);
+            }
         }
 
         this.emit("contacts-changed::" + baseNick, member.alias);
@@ -244,6 +250,12 @@ const UserTracker = new Lang.Class({
                 this._setNotifyActionEnabled(member.alias, true);
 
                 this._app.withdraw_notification(this._getNotifyActionNameInternal(member.alias));
+
+                // HACK: The member is no longer joined any public rooms, so
+                //       assume they disconnected and remove them from all
+                //       private chats as well
+                for (let r of this._roomData.keys())
+                    this._untrackMember(member, r);
             }
             this.emit("contacts-changed::" + baseNick, member.alias);
         }


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