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



commit 036098e669d989b0039bf0a846b9accba6608a52
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 a5cf904..d6b0403 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)
@@ -600,6 +601,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 62d224f..a9d9155 100644
--- a/src/gs-page.h
+++ b/src/gs-page.h
@@ -90,6 +90,7 @@ gboolean       gs_page_setup                          (GsPage         *page,
                                                         GtkBuilder     *builder,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
+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 a245dc7..1e361b1 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -1226,6 +1226,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)
@@ -1234,6 +1254,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]