[polari/gnome-3-20] roomList: Connect channel signals immediately if possible



commit 6b2f668a0f7fcbb60011b7a363e4ae5d5dcbe652
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jul 15 17:59:02 2016 +0200

    roomList: Connect channel signals immediately if possible
    
    We use the channel's ::message-received and ::pending-message-removed
    signals to mark rooms as active/inactive and update the highlight
    counter. Currently we are only connecting to those signals when the
    room's channel changed, so we fail to update rows for rooms that
    already had a channel when added to the list. While this is not the
    common case, it can still happen, e.g. when someone initiates a
    private chat with us or when re-launched by mission-control after
    a crash.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768909

 src/roomList.js |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 2fa6c88..24e5782 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -38,19 +38,13 @@ const RoomRow = new Lang.Class({
         this.connect('key-press-event',
                      Lang.bind(this, this._onKeyPress));
 
-        room.connect('notify::channel', Lang.bind(this,
-            function() {
-                if (!room.channel)
-                    return;
-                room.channel.connect('message-received',
-                                     Lang.bind(this, this._updatePending));
-                room.channel.connect('pending-message-removed',
-                                     Lang.bind(this, this._updatePending));
-            }));
+        room.connect('notify::channel',
+                     Lang.bind(this, this._onChannelChanged));
         room.bind_property('display-name', this._roomLabel, 'label',
                            GObject.BindingFlags.SYNC_CREATE);
 
         this._updatePending();
+        this._onChannelChanged();
     },
 
     get room() {
@@ -98,6 +92,16 @@ const RoomRow = new Lang.Class({
             context.remove_class('inactive');
     },
 
+    _onChannelChanged: function() {
+        if (!this._room.channel)
+            return;
+        this._room.channel.connect('message-received',
+                                   Lang.bind(this, this._updatePending));
+        this._room.channel.connect('pending-message-removed',
+                                   Lang.bind(this, this._updatePending));
+        this._updatePending();
+    },
+
     _onButtonRelease: function(w, event) {
         let [, button] = event.get_button();
         if (button != Gdk.BUTTON_SECONDARY)


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