[gnome-software/1526-some-plugins-for-obs-studio-mysteriously-dissapear] gs-details-page: Addons section can show addons for a different app



commit 580ebd1cd86f230458ebf98af5d7942547ba8c5d
Author: Milan Crha <mcrha redhat com>
Date:   Tue Nov 2 16:08:23 2021 +0100

    gs-details-page: Addons section can show addons for a different app
    
    When the app changes during the initial load, the addons section could
    still show the previous app's addons. Let the whole Addons section
    be updated inside the refresh_all(), rather than just show/hide it.
    Similarly cover reviews on the app change during the initial load.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1526

 src/gs-details-page.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 5bdaaaf2c..a125215a2 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -58,7 +58,9 @@
                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL | \
                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION
 
+static void gs_details_page_refresh_addons (GsDetailsPage *self);
 static void gs_details_page_refresh_all (GsDetailsPage *self);
+static void gs_details_page_app_refine_cb (GObject *source, GAsyncResult *res, gpointer user_data);
 
 typedef enum {
        GS_DETAILS_PAGE_STATE_LOADING,
@@ -762,8 +764,24 @@ gs_details_page_get_alternates_cb (GObject *source_object,
 
        gs_details_page_update_origin_button (self, TRUE);
 
-       if (instance_changed)
+       if (instance_changed) {
+               g_autoptr(GsPluginJob) plugin_job = NULL;
+
+               /* Make sure the changed instance contains the reviews and such */
+               plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
+                                                "app", self->app,
+                                                "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING |
+                                                                
GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS |
+                                                                GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS |
+                                                                GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE,
+                                                NULL);
+               gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job,
+                                                   self->cancellable,
+                                                   gs_details_page_app_refine_cb,
+                                                   self);
+
                gs_details_page_refresh_all (self);
+       }
 }
 
 static gboolean
@@ -1139,7 +1157,7 @@ gs_details_page_refresh_all (GsDetailsPage *self)
        /* update progress */
        gs_details_page_refresh_progress (self);
 
-       gtk_widget_set_visible (self->box_addons, gtk_widget_get_first_child (self->list_box_addons) != NULL);
+       gs_details_page_refresh_addons (self);
 }
 
 static gint
@@ -1191,7 +1209,7 @@ static void
 gs_details_page_refresh_addons (GsDetailsPage *self)
 {
        GsAppList *addons;
-       guint i;
+       guint i, rows = 0;
 
        gs_widget_remove_all (self->list_box_addons, (GsRemoveFunc) gtk_list_box_remove);
 
@@ -1218,9 +1236,11 @@ gs_details_page_refresh_addons (GsDetailsPage *self)
                                  self);
 
                gtk_list_box_append (GTK_LIST_BOX (self->list_box_addons), row);
-               gtk_widget_show (row);
 
+               rows++;
        }
+
+       gtk_widget_set_visible (self->box_addons, rows > 0);
 }
 
 static void gs_details_page_refresh_reviews (GsDetailsPage *self);
@@ -1499,7 +1519,6 @@ gs_details_page_load_stage2 (GsDetailsPage *self)
        gs_screenshot_carousel_load_screenshots (GS_SCREENSHOT_CAROUSEL (self->screenshot_carousel), 
self->app, is_online, NULL);
        has_screenshots = gs_screenshot_carousel_get_has_screenshots (GS_SCREENSHOT_CAROUSEL 
(self->screenshot_carousel));
        gtk_widget_set_visible (self->screenshot_carousel, has_screenshots);
-       gs_details_page_refresh_addons (self);
        gs_details_page_refresh_reviews (self);
        gs_details_page_refresh_all (self);
        gs_details_page_update_origin_button (self, FALSE);
@@ -1897,9 +1916,6 @@ gs_details_page_addon_selected_cb (GsAppAddonRow *row,
                } else {
                        g_set_object (&self->app_cancellable, gs_app_get_cancellable (addon));
                        gs_page_remove_app (GS_PAGE (self), addon, self->app_cancellable);
-                       /* make sure the addon checkboxes are synced if the
-                        * user clicks cancel in the remove confirmation dialog */
-                       gs_details_page_refresh_addons (self);
                        gs_details_page_refresh_all (self);
                }
                break;


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