[gnome-software/gnome-3-22] Do not reload the updates list when updates are in progress



commit 1d28bb1967a3a6586cc5154995ab27a3becfde16
Author: Richard Hughes <richard hughsie com>
Date:   Fri Mar 3 22:20:04 2017 +0000

    Do not reload the updates list when updates are in progress
    
    Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=779463

 src/gs-page.c          |    9 +++++++++
 src/gs-page.h          |    1 +
 src/gs-shell-updates.c |   26 ++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-page.c b/src/gs-page.c
index 931c57e..54af8e4 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -37,6 +37,7 @@ typedef struct
        GsShell                 *shell;
        GtkWidget               *header_start_widget;
        GtkWidget               *header_end_widget;
+       gboolean                 is_active;
 } GsPagePrivate;
 
 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GsPage, gs_page, GTK_TYPE_BIN)
@@ -620,6 +621,14 @@ gs_page_shortcut_remove (GsPage *page, GsApp *app, GCancellable *cancellable)
                                           NULL);
 }
 
+gboolean
+gs_page_is_active (GsPage *page)
+{
+       GsPagePrivate *priv = gs_page_get_instance_private (page);
+       g_return_val_if_fail (GS_IS_PAGE (page), FALSE);
+       return priv->is_active;
+}
+
 /**
  * gs_page_switch_to:
  *
diff --git a/src/gs-page.h b/src/gs-page.h
index 1f6b59c..de05fe2 100644
--- a/src/gs-page.h
+++ b/src/gs-page.h
@@ -79,6 +79,7 @@ void           gs_page_setup                          (GsPage         *page,
                                                         GsShell        *shell,
                                                         GsPluginLoader *plugin_loader,
                                                         GCancellable   *cancellable);
+gboolean        gs_page_is_active                      (GsPage         *page);
 
 G_END_DECLS
 
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index e5a862b..a74a3b0 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -1241,6 +1241,26 @@ gs_shell_updates_invalidate_downloaded_upgrade (GsShellUpdates *self)
                 gs_app_get_id (app));
 }
 
+static gboolean
+gs_shell_update_are_updates_in_progress (GsShellUpdates *self)
+{
+       GsUpdateList *update_list = GS_UPDATE_LIST (self->list_box_updates);
+       g_autoptr(GsAppList) list = gs_update_list_get_apps (update_list);
+       for (guint i = 0; i < gs_app_list_length (list); i++) {
+               GsApp *app = gs_app_list_index (list, i);
+               switch (gs_app_get_state (app)) {
+               case AS_APP_STATE_INSTALLING:
+               case AS_APP_STATE_REMOVING:
+               case AS_APP_STATE_PURCHASING:
+                       return TRUE;
+                       break;
+               default:
+                       break;
+               }
+       }
+       return FALSE;
+}
+
 static void
 gs_shell_updates_changed_cb (GsPluginLoader *plugin_loader,
                             GsShellUpdates *self)
@@ -1249,6 +1269,12 @@ gs_shell_updates_changed_cb (GsPluginLoader *plugin_loader,
         * then make sure all new packages are downloaded */
        gs_shell_updates_invalidate_downloaded_upgrade (self);
 
+       /* check to see if any apps in the app list are in a processing state */
+       if (gs_shell_update_are_updates_in_progress (self)) {
+               g_debug ("ignoring updates-changed as updates in progress");
+               return;
+       }
+
        /* refresh updates list */
        gs_shell_updates_reload (GS_PAGE (self));
 }


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