[polari/gnome-3-32] roomList: Always clear connecting indication on status change



commit fd6a1c1eb0d35e011e4f958f4c66ef82ed8adfd9
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun May 12 06:02:35 2019 +0200

    roomList: Always clear connecting indication on status change
    
    When joining a room takes longer than three seconds after establishing
    the connection, we show an indication to convey progress to the user.
    
    That indication is hidden again when either the room is joined, or the
    connection status changes again. However there is a window that allows
    the indicator to get stuck: If the event that hides the indicator happens
    *before* the three-second timeout is triggered, then we end up showing
    the indicator anyway.
    
    Make sure to cancel the timeout properly in those cases.
    
    https://gitlab.gnome.org/GNOME/polari/merge_requests/120

 src/roomList.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index a033fab..bdba7ee 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -69,9 +69,7 @@ var RoomRow = GObject.registerClass({
             });
             if (connectionStatusChangedId)
                 this.account.disconnect(connectionStatusChangedId);
-            if (this._connectingTimeoutId)
-                GLib.source_remove(this._connectingTimeoutId);
-            this._connectingTimeoutId = 0;
+            this._clearConnectingTimeout();
         });
 
         this._updatePending();
@@ -130,6 +128,7 @@ var RoomRow = GObject.registerClass({
                 return GLib.SOURCE_REMOVE;
             });
         } else {
+            this._clearConnectingTimeout();
             this._eventStack.visible_child_name = 'messages';
         }
     }
@@ -152,6 +151,7 @@ var RoomRow = GObject.registerClass({
 
         if (!this._room.channel)
             return;
+        this._clearConnectingTimeout();
         this._eventStack.visible_child_name = 'messages';
 
         for (let signal of ['message-received', 'pending-message-removed']) {
@@ -201,6 +201,12 @@ var RoomRow = GObject.registerClass({
         }
         this._popover.show();
     }
+
+    _clearConnectingTimeout() {
+        if (this._connectingTimeoutId)
+            GLib.source_remove(this._connectingTimeoutId);
+        this._connectingTimeoutId = 0;
+    }
 });
 
 var RoomListHeader = GObject.registerClass({


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