[gnome-software: 2/8] appstream: Make listing featured apps asynchronous




commit 6a204ce4a9860e0127105d486f197a59cfa1279b
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon May 23 13:55:43 2022 +0100

    appstream: Make listing featured apps asynchronous
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 plugins/core/gs-plugin-appstream.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 200676b21..488db5384 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -1382,22 +1382,6 @@ gs_plugin_add_categories (GsPlugin *plugin,
                                            cancellable, error);
 }
 
-gboolean
-gs_plugin_add_featured (GsPlugin *plugin,
-                       GsAppList *list,
-                       GCancellable *cancellable,
-                       GError **error)
-{
-       GsPluginAppstream *self = GS_PLUGIN_APPSTREAM (plugin);
-       g_autoptr(GRWLockReaderLocker) locker = NULL;
-
-       if (!gs_plugin_appstream_check_silo (self, cancellable, error))
-               return FALSE;
-
-       locker = g_rw_lock_reader_locker_new (&self->silo_lock);
-       return gs_appstream_add_featured (self->silo, list, cancellable, error);
-}
-
 static void list_apps_thread_cb (GTask        *task,
                                  gpointer      source_object,
                                  gpointer      task_data,
@@ -1437,6 +1421,7 @@ list_apps_thread_cb (GTask        *task,
        GsPluginListAppsData *data = task_data;
        GDateTime *released_since = NULL;
        GsAppQueryTristate is_curated = GS_APP_QUERY_TRISTATE_UNSET;
+       GsAppQueryTristate is_featured = GS_APP_QUERY_TRISTATE_UNSET;
        GsCategory *category = NULL;
        GsAppQueryTristate is_installed = GS_APP_QUERY_TRISTATE_UNSET;
        guint64 age_secs = 0;
@@ -1447,6 +1432,7 @@ list_apps_thread_cb (GTask        *task,
        if (data->query != NULL) {
                released_since = gs_app_query_get_released_since (data->query);
                is_curated = gs_app_query_get_is_curated (data->query);
+               is_featured = gs_app_query_get_is_featured (data->query);
                category = gs_app_query_get_category (data->query);
                is_installed = gs_app_query_get_is_installed (data->query);
        }
@@ -1460,9 +1446,11 @@ list_apps_thread_cb (GTask        *task,
         * Also don’t currently support GS_APP_QUERY_TRISTATE_FALSE. */
        if ((released_since == NULL &&
             is_curated == GS_APP_QUERY_TRISTATE_UNSET &&
+            is_featured == GS_APP_QUERY_TRISTATE_UNSET &&
             category == NULL &&
             is_installed == GS_APP_QUERY_TRISTATE_UNSET) ||
            is_curated == GS_APP_QUERY_TRISTATE_FALSE ||
+           is_featured == GS_APP_QUERY_TRISTATE_FALSE ||
            is_installed == GS_APP_QUERY_TRISTATE_FALSE ||
            gs_app_query_get_n_properties_set (data->query) != 1) {
                g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
@@ -1491,6 +1479,12 @@ list_apps_thread_cb (GTask        *task,
                return;
        }
 
+       if (is_featured != GS_APP_QUERY_TRISTATE_UNSET &&
+           !gs_appstream_add_featured (self->silo, list, cancellable, &local_error)) {
+               g_task_return_error (task, g_steal_pointer (&local_error));
+               return;
+       }
+
        if (category != NULL &&
            !gs_appstream_add_category_apps (GS_PLUGIN (self), self->silo, category, list, cancellable, 
&local_error)) {
                g_task_return_error (task, g_steal_pointer (&local_error));


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