[gnome-software/859-app-has-been-installed-notifications-sit-around-indefinitely] gs-common: Auto-withdraw install/restart notifications after 24 hours



commit 8eef5736dd13d4fd97fac09365ebe65c6e1b2e32
Author: Milan Crha <mcrha redhat com>
Date:   Fri May 13 09:59:59 2022 +0200

    gs-common: Auto-withdraw install/restart notifications after 24 hours
    
    That's for "app had been installed" and "requires restart" notifications
    only at the moment.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/859

 src/gs-common.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
---
diff --git a/src/gs-common.c b/src/gs-common.c
index a6cbda8df..5f7ccb08b 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -116,6 +116,27 @@ gs_grab_focus_when_mapped (GtkWidget *widget)
                                        G_CALLBACK (grab_focus), NULL);
 }
 
+static guint withdraw_notifications_id = 0;
+
+static gboolean
+gs_common_withdraw_notifications_cb (gpointer user_data)
+{
+       withdraw_notifications_id = 0;
+
+       gs_utils_withdraw_notifications (NULL);
+
+       return G_SOURCE_REMOVE;
+}
+
+static void
+gs_common_schedule_withdraw_notifications (void)
+{
+       if (withdraw_notifications_id)
+               g_source_remove (withdraw_notifications_id);
+       withdraw_notifications_id = g_timeout_add_seconds (24 * 60 * 60,
+               gs_common_withdraw_notifications_cb, NULL);
+}
+
 void
 gs_app_notify_installed (GsApp *app)
 {
@@ -179,6 +200,7 @@ gs_app_notify_installed (GsApp *app)
        g_notification_set_default_action_and_target  (n, "app.details", "(ss)",
                                                       gs_app_get_unique_id (app), "");
        g_application_send_notification (g_application_get_default (), "installed", n);
+       gs_common_schedule_withdraw_notifications ();
 }
 
 typedef enum {
@@ -834,6 +856,7 @@ gs_utils_reboot_notify (GsAppList *list,
        g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
        g_notification_set_priority (n, G_NOTIFICATION_PRIORITY_URGENT);
        g_application_send_notification (g_application_get_default (), "restart-required", n);
+       gs_common_schedule_withdraw_notifications ();
 }
 
 /**


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