Change emit from installed-changed to app-state-changed
Rename variable to avoid clash
Revert emit back to installed-changed
Add workaround for the race condition when workspaces are switched too quickly