[gnome-software/1504-drop-older-versions-from-update-details-dialog] gs-appstream: Limit what update details are used




commit c0e96f0c132d2f7ebd5b26eb7f3f9509cb54396b
Author: Milan Crha <mcrha redhat com>
Date:   Tue Oct 26 17:51:40 2021 +0200

    gs-appstream: Limit what update details are used
    
    Show only update details between the currently installed version
    and the version for the update. No need to show older versions.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1504

 lib/gs-appstream.c             | 9 ++++++++-
 plugins/flatpak/gs-self-test.c | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index df91dd0fd..e0b9cc8c5 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -550,12 +550,18 @@ gs_appstream_refine_app_updates (GsApp *app,
 
        /* get the descriptions with a version prefix */
        } else if (updates_list->len > 1) {
+               const gchar *version = gs_app_get_version (app);
                g_autoptr(GString) update_desc = g_string_new ("");
                for (guint i = 0; i < updates_list->len; i++) {
                        XbNode *release = g_ptr_array_index (updates_list, i);
+                       const gchar *release_version = xb_node_get_attr (release, "version");
                        g_autofree gchar *desc = NULL;
                        g_autoptr(XbNode) n = NULL;
 
+                       /* skip the currently installed version and all below it */
+                       if (version != NULL && as_vercmp_simple (version, release_version) >= 0)
+                               continue;
+
                        n = xb_node_query_first (release, "description", NULL);
                        desc = gs_appstream_format_description (n, NULL);
                        g_string_append_printf (update_desc,
@@ -567,7 +573,8 @@ gs_appstream_refine_app_updates (GsApp *app,
                /* remove trailing newlines */
                if (update_desc->len > 2)
                        g_string_truncate (update_desc, update_desc->len - 2);
-               gs_app_set_update_details (app, update_desc->str);
+               if (update_desc->len > 0)
+                       gs_app_set_update_details (app, update_desc->str);
        }
 
        /* if there is no already set update version use the newest */
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index fccc11027..13e2bb7b4 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -1511,7 +1511,7 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
        app = gs_app_list_lookup (list_updates, "*/flatpak/test/org.test.Chiron/*");
        g_assert_nonnull (app);
        g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_UPDATABLE_LIVE);
-       g_assert_cmpstr (gs_app_get_update_details (app), ==, "Version 1.2.4:\nThis is best.\n\nVersion 
1.2.3:\nThis is better.");
+       g_assert_cmpstr (gs_app_get_update_details (app), ==, "Version 1.2.4:\nThis is best.");
        g_assert_cmpstr (gs_app_get_update_version (app), ==, "1.2.4");
 
        /* care about signals */


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