Skip to content

Commit

Permalink
FlatpakBackend: set action enabled in main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Jun 20, 2024
1 parent 1c0b22b commit 6f5d886
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Core/FlatpakBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public class AppCenterCore.FlatpakBackend : Object {
var job = jobs.pop ();
job_type = job.operation;
working = true;
set_actions_enabled (working);

if (remove_inhibit_timeout != 0) {
Source.remove (remove_inhibit_timeout);
Expand Down Expand Up @@ -155,7 +154,6 @@ public class AppCenterCore.FlatpakBackend : Object {
}

working = false;
set_actions_enabled (working);
}

return true;
Expand Down Expand Up @@ -242,12 +240,13 @@ public class AppCenterCore.FlatpakBackend : Object {
);

reload_appstream_pool ();
}

private void set_actions_enabled (bool working) {
var app = Application.get_default ();
((SimpleAction) app.lookup_action ("refresh")).set_enabled (!working && !Utils.is_running_in_guest_session ());
((SimpleAction) app.lookup_action ("repair")).set_enabled (!working);
// Need to set actions in this thread
notify["working"].connect (() => {
var app = Application.get_default ();
((SimpleAction) app.lookup_action ("refresh")).set_enabled (!working && !Utils.is_running_in_guest_session ());
((SimpleAction) app.lookup_action ("repair")).set_enabled (!working);
});
}

private async void trigger_update_check () {
Expand Down

0 comments on commit 6f5d886

Please sign in to comment.