[gnome-software/mwleeds/fix-deprecated-install: 124/127] flatpak: Don't use GS_APP_STATE_AVAILABLE_LOCAL for flatpakref files




commit bafd0b525f9407ed0c98ccd989ea573fcf524b16
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Wed Nov 3 14:10:31 2021 -0700

    flatpak: Don't use GS_APP_STATE_AVAILABLE_LOCAL for flatpakref files
    
    Use GS_APP_STATE_AVAILABLE instead. While the flatpakref file is
    available locally, the app is available in a remote repo pointed to by
    the local file. If you look at the places where the AVAILABLE_LOCAL
    state is checked, they assume it doesn't make sense to check remote data
    if something is locally available, but in the case of a flatpakref, a
    remote will have been created and it does make sense to check it. The
    only place where it is questionable whether GS_APP_STATE_AVAILABLE is
    what we want for these files is in gs_details_page_refresh_all(), where
    the "Software Repository Included" (infobar_details_app_repo) message is
    shown for AVAILABLE_LOCAL apps. However gs_flatpak_file_to_app_ref()
    adds the origin remote from the flatpakref before displaying the details
    page to the user to let them choose whether to install the app, whereas
    the "Software Repository Included" dialog might make the user think the
    repo would be added upon installation, so it is possibly good to avoid
    it.
    
    This change affects the UI when a flatpakref file is loaded: instead of
    showing "Local file (Flatpak)" as the Source in the top right corner,
    with the full filename available if you click on it, we now show
    "Flathub (Flatpak)" as the source, which to me seems more accurate.

 plugins/flatpak/gs-flatpak.c        |  2 +-
 plugins/flatpak/gs-plugin-flatpak.c |  2 +-
 plugins/flatpak/gs-self-test.c      | 11 ++++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 8f54af440..a771b87cb 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -3603,7 +3603,7 @@ gs_flatpak_file_to_app_ref (GsFlatpak *self,
 
        gs_app_add_quirk (app, GS_APP_QUIRK_HAS_SOURCE);
        gs_flatpak_app_set_file_kind (app, GS_FLATPAK_APP_FILE_KIND_REF);
-       gs_app_set_state (app, GS_APP_STATE_AVAILABLE_LOCAL);
+       gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
 
        /* use the data from the flatpakref file as a fallback */
        ref_title = g_key_file_get_string (kf, "Flatpak Ref", "Title", NULL);
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index f867c24fd..e5121276c 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -1397,7 +1397,7 @@ gs_plugin_flatpak_file_to_app_ref (GsPluginFlatpak  *self,
                } else {
                        /* the new runtime is available from the RuntimeRepo */
                        if (gs_flatpak_app_get_runtime_url (runtime) != NULL)
-                               gs_app_set_state (runtime, GS_APP_STATE_AVAILABLE_LOCAL);
+                               gs_app_set_state (runtime, GS_APP_STATE_AVAILABLE);
                }
        }
 
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index 9052ae0e0..6f752238a 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -727,7 +727,7 @@ gs_plugins_flatpak_runtime_repo_func (GsPluginLoader *plugin_loader)
        g_assert_no_error (error);
        g_assert_true (app != NULL);
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_DESKTOP_APP);
-       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
+       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);
        g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
        g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
                        "user/flatpak/*/org.test.Chiron/master"));
@@ -736,7 +736,7 @@ gs_plugins_flatpak_runtime_repo_func (GsPluginLoader *plugin_loader)
        /* get runtime */
        runtime = gs_app_get_runtime (app);
        g_assert_cmpstr (gs_app_get_unique_id (runtime), ==, "user/flatpak/test/org.test.Runtime/master");
-       g_assert_cmpint (gs_app_get_state (runtime), ==, GS_APP_STATE_AVAILABLE_LOCAL);
+       g_assert_cmpint (gs_app_get_state (runtime), ==, GS_APP_STATE_AVAILABLE);
 
        /* check the number of sources */
        g_object_unref (plugin_job);
@@ -890,7 +890,7 @@ gs_plugins_flatpak_runtime_repo_redundant_func (GsPluginLoader *plugin_loader)
        g_assert_no_error (error);
        g_assert_true (app != NULL);
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_DESKTOP_APP);
-       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
+       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);
        g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
        g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
                        "user/flatpak/*/org.test.Chiron/master"));
@@ -1035,7 +1035,7 @@ gs_plugins_flatpak_broken_remote_func (GsPluginLoader *plugin_loader)
        g_assert_no_error (error);
        g_assert_true (app != NULL);
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_DESKTOP_APP);
-       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
+       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);
        g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
        g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
                        "user/flatpak/test/org.test.Chiron/master"));
@@ -1186,7 +1186,6 @@ flatpak_bundle_or_ref_helper (GsPluginLoader *plugin_loader,
        g_assert_no_error (error);
        g_assert_true (app != NULL);
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_DESKTOP_APP);
-       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
        g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
        g_assert_cmpstr (gs_app_get_name (app), ==, "Chiron");
        g_assert_cmpstr (gs_app_get_summary (app), ==, "Single line synopsis");
@@ -1199,10 +1198,12 @@ flatpak_bundle_or_ref_helper (GsPluginLoader *plugin_loader,
                g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
                                "user/flatpak/flatpak/org.test.Chiron/master"));
                g_assert_true (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_BUNDLE);
+               g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
        } else {
                g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
                                "user/flatpak/test/org.test.Chiron/master"));
                g_assert_true (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_REF);
+               g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);
                g_assert_cmpstr (gs_app_get_url (app, AS_URL_KIND_HOMEPAGE), ==, "http://127.0.0.1/";);
                g_assert_cmpstr (gs_app_get_description (app), ==, "Long description.");
        }


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