[polari] telepathyClient: Fix acknowledging pending messages on close



commit 17d4b7c9f69a8c5155849c714e6719213e97fe9f
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Sep 9 18:45:25 2016 +0200

    telepathyClient: Fix acknowledging pending messages on close
    
    Oh my, this is embarrassing: The actual method to remove all
    pending messages is ack_all_pending_messages_*async*. Commit
    5d07f45190 "worked" by triggering an exception before actually
    leaving the channel, so the channel didn't pop up again because
    it was never gone in the first place (though hidden from the UI).
    It turns out that using the correct method doesn't fully work
    either here, as the ::pending-message-removed handler relies on
    the corresponding room which is gone when the signal is emitted.
    We can work around this by acknowledging messages one-by-one and
    running the handler manually, so do that to fix the original issue.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768611

 src/telepathyClient.js |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 63f3a38..a3299d0 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -367,7 +367,13 @@ const TelepathyClient = new Lang.Class({
 
         // This is a user action, so acknowledge messages to prevent
         // mission-control from popping up the channel again
-        room.channel.ack_all_pending_messages(null);
+        room.channel.dup_pending_messages().forEach(m => {
+            // The room is about to be removed and will gone when the
+            // ::pending-message-removed signal is emitted, so just
+            // withdraw pending notifications now
+            this._onPendingMessageRemoved(room.channel, m);
+            room.channel.ack_message_async(m, null);
+        });
 
         let reason = Tp.ChannelGroupChangeReason.NONE;
         message = message || _("Good Bye");
@@ -578,6 +584,9 @@ const TelepathyClient = new Lang.Class({
             return;
 
         let room = this._roomManager.lookupRoomByChannel(channel);
+        if (!room)
+            return;
+
         this._app.withdraw_notification(this._getPendingNotificationID(room, id));
     }
 });


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