[connections/fix-rdp-auth-issues: 4/4] notifications: Don't show AuthNotifications in collection view




commit 45f37f184658e46e1ad63b30c2e01c1898ece444
Author: Felipe Borges <felipeborges gnome org>
Date:   Fri Aug 6 10:49:02 2021 +0200

    notifications: Don't show AuthNotifications in collection view
    
    This is a bug when a user attempts a connection but closes it
    before attending the authentication dialog.

 src/notifications.vala | 17 ++++++++++++-----
 src/window.vala        |  6 +++++-
 2 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/src/notifications.vala b/src/notifications.vala
index 84d250e..3394e82 100644
--- a/src/notifications.vala
+++ b/src/notifications.vala
@@ -25,7 +25,7 @@ namespace Connections {
         private const int MAX_NOTIFICATIONS = 5;
 
         private Gtk.Widget? _active_notification;
-        private Gtk.Widget? active_notification {
+        public Gtk.Widget? active_notification {
             get {
                 return _active_notification;
             }
@@ -79,12 +79,19 @@ namespace Connections {
             return notification;
         }
 
-        public void dismiss_any_notification () {
+        public void dismiss () {
             if (active_notification != null) {
-                Notification? child = active_notification as Notification;
-                if (child != null) {
-                    child.dismiss ();
+                // TODO: Make AuthNotification derived from Notification
+                if (active_notification is Notification) {
+                    Notification? notification = active_notification as Notification;
+
+                    notification.dismiss ();
+                } else if (active_notification is AuthNotification) {
+                    AuthNotification? notification = active_notification as AuthNotification;
+                    notification.dismiss ();
                 }
+
+                active_notification = null;
             }
         }
     }
diff --git a/src/window.vala b/src/window.vala
index 267c1d4..e81fef6 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -106,6 +106,10 @@ namespace Connections {
 
             topbar.show_collection_view ();
             topbar.set_title (_("Connections"));
+
+            if (notifications_bar.active_notification is AuthNotification) {
+                notifications_bar.dismiss ();
+            }
         }
 
         public void show_preferences_window (Connection connection) {
@@ -151,7 +155,7 @@ namespace Connections {
 
         [GtkCallback]
         private bool on_delete_event () {
-            notifications_bar.dismiss_any_notification ();
+            notifications_bar.dismiss ();
 
             return false;
         }


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