[polari] roomList: Always clear connecting indication on status change



commit 7f8e0dbf5b3dc037c3850d9937974af3266f2bef
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 7b622d8..9752fab 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -71,9 +71,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();
@@ -132,6 +130,7 @@ var RoomRow = GObject.registerClass({
                 return GLib.SOURCE_REMOVE;
             });
         } else {
+            this._clearConnectingTimeout();
             this._eventStack.visible_child_name = 'messages';
         }
     }
@@ -154,6 +153,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']) {
@@ -203,6 +203,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]