From 2fba24ccae13e832bd38ff9c7fea71c1a802603d Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 7 Sep 2023 21:30:47 +0200 Subject: Fix subscription notification clearing --- .../conversation_view.vala | 6 +++++ main/src/ui/notifier_freedesktop.vala | 29 +++++++++++++--------- 2 files changed, 23 insertions(+), 12 deletions(-) (limited to 'main/src') diff --git a/main/src/ui/conversation_content_view/conversation_view.vala b/main/src/ui/conversation_content_view/conversation_view.vala index cc63037f..4006a02f 100644 --- a/main/src/ui/conversation_content_view/conversation_view.vala +++ b/main/src/ui/conversation_content_view/conversation_view.vala @@ -606,6 +606,12 @@ public class ConversationView : Widget, Plugins.ConversationItemCollection, Plug widget.dispose(); } widgets.clear(); + + Widget? notification = notifications.get_first_child(); + while (notification != null) { + notifications.remove(notification); + notification = notifications.get_first_child(); + } } private void clear_notifications() { diff --git a/main/src/ui/notifier_freedesktop.vala b/main/src/ui/notifier_freedesktop.vala index 3f390102..a1df5990 100644 --- a/main/src/ui/notifier_freedesktop.vala +++ b/main/src/ui/notifier_freedesktop.vala @@ -273,23 +273,28 @@ public class Dino.Ui.FreeDesktopNotifier : NotificationProvider, Object { } public async void retract_content_item_notifications() { - if (content_notifications != null) { - foreach (uint32 id in content_notifications.values) { - try { - dbus_notifications.close_notification.begin(id); - } catch (Error e) { } - } - content_notifications.clear(); + foreach (uint32 id in content_notifications.values) { + try { + dbus_notifications.close_notification.begin(id); + } catch (Error e) { } } + content_notifications.clear(); } public async void retract_conversation_notifications(Conversation conversation) { - if (content_notifications.has_key(conversation)) { - try { + try { + if (content_notifications.has_key(conversation)) { dbus_notifications.close_notification.begin(content_notifications[conversation]); - } catch (Error e) { } - } - content_notifications.unset(conversation); + content_notifications.unset(conversation); + } + + if (conversation_notifications.has_key(conversation)) { + foreach (var notification_id in conversation_notifications[conversation]) { + dbus_notifications.close_notification.begin(notification_id); + } + conversation_notifications.unset(conversation); + } + } catch (Error e) { } } private async Variant get_conversation_icon(Conversation conversation) { -- cgit v1.2.3-54-g00ecf