Skip to content

Commit

Permalink
Wrap in idle instead
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Jun 20, 2024
1 parent 6f5d886 commit b3977cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Core/FlatpakBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ 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 @@ -154,6 +155,7 @@ public class AppCenterCore.FlatpakBackend : Object {
}

working = false;
set_actions_enabled (working);
}

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

reload_appstream_pool ();
}

// Need to set actions in this thread
notify["working"].connect (() => {
private void set_actions_enabled (bool working) {
// Make sure we run on the main thread
Idle.add_once (() => {
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);
Expand Down

0 comments on commit b3977cd

Please sign in to comment.