[gnome-software/mwleeds/hardcoded-pwa-list] fixup! epiphany: Refine appstream-provided web apps



commit f72af110afe8190db6cb78b55e72759502d8b6a6
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Tue Mar 15 17:04:35 2022 -0700

    fixup! epiphany: Refine appstream-provided web apps

 plugins/epiphany/gs-plugin-epiphany.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 5f1f0845b..852b35450 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -396,6 +396,8 @@ refine_app (GsApp      *app,
        gs_app_set_origin (app, "gnome-web");
        gs_app_set_origin_ui (app, _("GNOME Web"));
 
+       gs_app_set_scope (app, AS_COMPONENT_SCOPE_USER);
+
        /* 1 is a special value meaning 0 */
        gs_app_set_size_download (app, 1);
 
@@ -453,7 +455,6 @@ gs_epiphany_create_app (GsPluginEpiphany *self,
        app = gs_app_new (id);
        gs_app_set_management_plugin (app, GS_PLUGIN (self));
        gs_app_set_kind (app, AS_COMPONENT_KIND_WEB_APP);
-       gs_app_set_scope (app, AS_COMPONENT_SCOPE_USER);
 
        gs_plugin_cache_add (GS_PLUGIN (self), id, app);
        return g_steal_pointer (&app);
@@ -687,6 +688,22 @@ refine_thread_cb (GTask        *task,
                        continue;
                }
 
+               if (gs_app_get_state (app) == GS_APP_STATE_UNKNOWN) {
+                       g_autoptr(GsApp) cached_app = NULL;
+                       g_autofree char *desktop_file_id = NULL;
+
+                       desktop_file_id = g_strconcat (id, ".desktop", NULL);
+
+                       /* Set the state to available unless we have a cached
+                        * app already, in which case it's probably installed
+                        */
+                       cached_app = gs_plugin_cache_lookup (GS_PLUGIN (self), desktop_file_id);
+                       if (cached_app)
+                               gs_app_set_state (app, gs_app_get_state (cached_app));
+                       else
+                               gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
+               }
+
                refine_app (app, uri, url);
        }
 


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