Store: Perform uninstalls on a background thread, to avoid hanging the UI

This commit is contained in:
Henrik Rydgård committed 2023-12-08 16:16:26 +01:00
1 parent a929eb6c6d
commit 888b32e243
4 files changed
+47 -34

No files matched your search

+4 -8
View File
@@ -266,7 +266,6 @@ private:
void CreateViews();
UI::EventReturn OnInstall(UI::EventParams &e);
UI::EventReturn OnCancel(UI::EventParams &e);
UI::EventReturn OnUninstall(UI::EventParams &e);
UI::EventReturn OnLaunchClick(UI::EventParams &e);
bool IsGameInstalled() {
@@ -309,7 +308,10 @@ void ProductView::CreateViews() {
installButton_ = nullptr;
speedView_ = nullptr;
Add(new TextView(st->T("Already Installed")));
Add(new Button(st->T("Uninstall")))->OnClick.Handle(this, &ProductView::OnUninstall);
Add(new Button(st->T("Uninstall")))->OnClick.Add([=](UI::EventParams &e) {
g_GameManager.UninstallGameOnThread(entry_.file);
return UI::EVENT_DONE;
});
launchButton_ = new Button(st->T("Launch Game"));
launchButton_->OnClick.Handle(this, &ProductView::OnLaunchClick);
Add(launchButton_);
@@ -387,12 +389,6 @@ UI::EventReturn ProductView::OnCancel(UI::EventParams &e) {
return UI::EVENT_DONE;
}
UI::EventReturn ProductView::OnUninstall(UI::EventParams &e) {
g_GameManager.Uninstall(entry_.file);
CreateViews();
return UI::EVENT_DONE;
}
UI::EventReturn ProductView::OnLaunchClick(UI::EventParams &e) {
if (g_GameManager.GetState() != GameManagerState::IDLE) {
// Button should have been disabled. Just a safety check.