[gnome-software/1150-gs-updates-page-keep-showing-apps-which-are-being-installed] gs-updates-page: Keep showing apps which are being installed



commit e79ed186d02e0fc1cd51b3ea415c7d742ef20f64
Author: Milan Crha <mcrha redhat com>
Date:   Fri Feb 19 09:26:16 2021 +0100

    gs-updates-page: Keep showing apps which are being installed
    
    When a user enters the Updates page and sees one Flatpak application for update, then
    he/she clicks "Update" and the application switches to the "installing" state and the user
    can watch the progress of the install. While the page is shown it can either refresh
    on its own or after user's intent to refresh the content. When it's done the page shows
    empty with "System is up to date", which is considered a lie, because there is still
    an ongoing update. This can be verified in the Installed page, where the application
    is shown as "installing".
    
    Rather than presenting the user suddenly empty Updates page, show there also applications,
    which are installing.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1150

 lib/gs-plugin-loader.c              |  2 +-
 lib/gs-plugin.c                     | 38 +++++++++++++++++++++++++++++++++++++
 lib/gs-plugin.h                     |  3 +++
 plugins/flatpak/gs-plugin-flatpak.c |  1 +
 src/gs-updates-page.c               |  3 ++-
 5 files changed, 45 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 2dad71f86..d9e31948f 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1338,7 +1338,7 @@ static gboolean
 gs_plugin_loader_app_is_valid_updatable (GsApp *app, gpointer user_data)
 {
        return gs_plugin_loader_app_is_valid (app, user_data) &&
-               gs_app_is_updatable (app);
+               (gs_app_is_updatable (app) || gs_app_get_state (app) == GS_APP_STATE_INSTALLING);
 }
 
 static gboolean
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index d91cd496b..7e9160463 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1399,6 +1399,44 @@ gs_plugin_cache_lookup (GsPlugin *plugin, const gchar *key)
        return g_object_ref (app);
 }
 
+/**
+ * gs_plugin_cache_lookup_by_state:
+ * @plugin: a #GsPlugin
+ * @list: a #GsAppList to add applications to
+ * @state: a #GsAppState
+ *
+ * Adds each cached #GsApp with state @state into the @list.
+ * When the state is %GS_APP_STATE_UNKNOWN, then adds all
+ * cached applications.
+ *
+ * Since: 40
+ **/
+void
+gs_plugin_cache_lookup_by_state (GsPlugin *plugin,
+                                GsAppList *list,
+                                GsAppState state)
+{
+       GsPluginPrivate *priv;
+       GHashTableIter iter;
+       gpointer value;
+       g_autoptr(GMutexLocker) locker = NULL;
+
+       g_return_if_fail (GS_IS_PLUGIN (plugin));
+       g_return_if_fail (GS_IS_APP_LIST (list));
+
+       priv = gs_plugin_get_instance_private (plugin);
+       locker = g_mutex_locker_new (&priv->cache_mutex);
+
+       g_hash_table_iter_init (&iter, priv->cache);
+       while (g_hash_table_iter_next (&iter, NULL, &value)) {
+               GsApp *app = value;
+
+               if (state == GS_APP_STATE_UNKNOWN ||
+                   state == gs_app_get_state (app))
+                       gs_app_list_add (list, app);
+       }
+}
+
 /**
  * gs_plugin_cache_remove:
  * @plugin: a #GsPlugin
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index 175b30612..ccff227ff 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -102,6 +102,9 @@ gboolean     gs_plugin_check_distro_id              (GsPlugin       *plugin,
                                                         const gchar    *distro_id);
 GsApp          *gs_plugin_cache_lookup                 (GsPlugin       *plugin,
                                                         const gchar    *key);
+void            gs_plugin_cache_lookup_by_state        (GsPlugin       *plugin,
+                                                        GsAppList      *list,
+                                                        GsAppState      state);
 void            gs_plugin_cache_add                    (GsPlugin       *plugin,
                                                         const gchar    *key,
                                                         GsApp          *app);
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 64e1898ff..3bb862fcd 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -257,6 +257,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
                if (!gs_flatpak_add_updates (flatpak, list, cancellable, error))
                        return FALSE;
        }
+       gs_plugin_cache_lookup_by_state (plugin, list, GS_APP_STATE_INSTALLING);
        return TRUE;
 }
 
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index 0b51283ee..01399820b 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -134,7 +134,8 @@ gs_updates_page_invalidate (GsUpdatesPage *self)
 static GsUpdatesSectionKind
 _get_app_section (GsApp *app)
 {
-       if (gs_app_get_state (app) == GS_APP_STATE_UPDATABLE_LIVE) {
+       if (gs_app_get_state (app) == GS_APP_STATE_UPDATABLE_LIVE ||
+           gs_app_get_state (app) == GS_APP_STATE_INSTALLING) {
                if (gs_app_get_kind (app) == AS_COMPONENT_KIND_FIRMWARE)
                        return GS_UPDATES_SECTION_KIND_ONLINE_FIRMWARE;
                return GS_UPDATES_SECTION_KIND_ONLINE;


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