[gnome-software: 3/4] gs-extras-page: Ensure page state always changes after loading results




commit 5a99510e9bd9a3f5238cccafe36867036406b186
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Oct 13 13:11:44 2021 +0100

    gs-extras-page: Ensure page state always changes after loading results
    
    Previously, if there was exactly one result for a codec search, that
    result would be shown (in a details page), but the state of the extras
    page would not be updated and hence would remain as
    `GS_EXTRAS_PAGE_STATE_LOADING`.
    
    This meant that if the user pressed the back button in the shell
    history, they would be taken back from the codec details page to an
    extras page which was forever loading.
    
    Fix that by always changing the extras page state, and then potentially
    showing the details for a single search result.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Fixes: #1473

 src/gs-extras-page.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/gs-extras-page.c b/src/gs-extras-page.c
index cb94ccb35..c55814687 100644
--- a/src/gs-extras-page.c
+++ b/src/gs-extras-page.c
@@ -536,18 +536,20 @@ show_search_results (GsExtrasPage *self)
                str = build_no_results_label (self);
                gtk_label_set_label (GTK_LABEL (self->label_no_results), str);
                gs_extras_page_set_state (self, GS_EXTRAS_PAGE_STATE_NO_RESULTS);
-       } else if (n_children == 1) {
-               /* switch directly to details view */
-               g_debug ("extras: found one result, showing in details view");
-               g_assert (first_child != NULL);
-               app = gs_app_row_get_app (GS_APP_ROW (first_child));
-               gs_shell_show_app (self->shell, app);
-               if (gs_app_is_installed (app))
-                       gs_extras_page_maybe_emit_installed_resources_done (self);
        } else {
                /* show what we got */
                g_debug ("extras: got %u search results, showing", n_children);
                gs_extras_page_set_state (self, GS_EXTRAS_PAGE_STATE_READY);
+
+               if (n_children == 1) {
+                       /* switch directly to details view */
+                       g_debug ("extras: found one result, showing in details view");
+                       g_assert (first_child != NULL);
+                       app = gs_app_row_get_app (GS_APP_ROW (first_child));
+                       gs_shell_show_app (self->shell, app);
+                       if (gs_app_is_installed (app))
+                               gs_extras_page_maybe_emit_installed_resources_done (self);
+               }
        }
 }
 


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