diff --git a/src/Core/FlatpakBackend.vala b/src/Core/FlatpakBackend.vala index adde2f618..a5cc8e729 100644 --- a/src/Core/FlatpakBackend.vala +++ b/src/Core/FlatpakBackend.vala @@ -1333,7 +1333,7 @@ public class AppCenterCore.FlatpakBackend : Object, Backend { package_list = new_package_list; - if (MainContext.get_thread_default () == null) { + if (Thread.self () != worker_thread) { // We are in the main thread so update immediately update_package_store (removed, added); } else { diff --git a/src/Core/Package.vala b/src/Core/Package.vala index 46e5d5deb..cc11a651a 100644 --- a/src/Core/Package.vala +++ b/src/Core/Package.vala @@ -147,11 +147,7 @@ public class AppCenterCore.Package : Object { return _component_id; } - _component_id = component.id; - if (_component_id.has_suffix (".desktop")) { - // ".desktop" is always 8 bytes in UTF-8 so we can just chop 8 bytes off the end - _component_id = _component_id.substring (0, _component_id.length - 8); - } + _component_id = Utils.normalize_component_id (component.id); return _component_id; } diff --git a/src/Utils.vala b/src/Utils.vala index 3a54b16aa..027f644c0 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -83,4 +83,13 @@ namespace Utils { public static bool is_running_in_guest_session () { return Environment.get_user_name ().has_prefix ("guest-"); } + + public static string normalize_component_id (string component_id) { + if (component_id.has_suffix (".desktop")) { + // ".desktop" is always 8 bytes in UTF-8 so we can just chop 8 bytes off the end + return component_id.substring (0, component_id.length - 8); + } + + return component_id; + } }