[gnome-software] update monitor: Notify about offline updates after they are downloaded



commit 23f0f57fdf8c6d7c0cddb3db00283ac8226803e6
Author: Kalev Lember <klember redhat com>
Date:   Tue Oct 23 10:12:25 2018 +0200

    update monitor: Notify about offline updates after they are downloaded
    
    The notification text says "updates are ready to be installed" so they'd
    better be ready when we notify the user.

 src/gs-update-monitor.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index 8f5d471f..9a3b76b3 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -333,6 +333,7 @@ download_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
        g_autoptr(GError) error = NULL;
        g_autoptr(GsAppList) list = NULL;
        g_autoptr(GsAppList) update_online = NULL;
+       g_autoptr(GsAppList) update_offline = NULL;
 
        /* get result */
        list = gs_plugin_loader_job_process_finish (GS_PLUGIN_LOADER (object), res, &error);
@@ -342,15 +343,19 @@ download_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
                return;
        }
 
-       /* install any apps that can be installed LIVE */
        update_online = gs_app_list_new ();
+       update_offline = gs_app_list_new ();
        for (guint i = 0; i < gs_app_list_length (list); i++) {
                GsApp *app = gs_app_list_index (list, i);
                if (_should_auto_update (app)) {
                        g_debug ("auto-updating %s", gs_app_get_unique_id (app));
                        gs_app_list_add (update_online, app);
+               } else {
+                       gs_app_list_add (update_offline, app);
                }
        }
+
+       /* install any apps that can be installed LIVE */
        if (gs_app_list_length (update_online) > 0) {
                g_autoptr(GsPluginJob) plugin_job = NULL;
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_UPDATE,
@@ -362,6 +367,14 @@ download_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
                                                    update_finished_cb,
                                                    monitor);
        }
+
+       /* show a notification for offline updates */
+       if (gs_app_list_length (update_offline) > 0) {
+               if (has_important_updates (update_offline) ||
+                   no_updates_for_a_week (monitor)) {
+                       notify_offline_update_available (monitor);
+               }
+       }
 }
 
 static void
@@ -422,11 +435,6 @@ get_updates_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
                                                    monitor);
                return;
        }
-
-       if (has_important_updates (apps) ||
-           no_updates_for_a_week (monitor)) {
-               notify_offline_update_available (monitor);
-       }
 }
 
 static gboolean


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