From 7b3fac18cd8073db97df5673c41ee72288b2e493 Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Mon, 18 Mar 2024 16:33:37 -0400 Subject: [PATCH] Remove synchronous achievement login Deletes AchievementManager::Login, renames LoginAsync to Login, and replaces the one synchronous call in the AchievementSettingsWidget with the async call. There is a minor usability regression in that the UI currently does not notify the user when a login has failed; this will be addressed in a later change (possibly in a different PR). --- Source/Core/Core/AchievementManager.cpp | 20 ++----------------- Source/Core/Core/AchievementManager.h | 3 +-- .../AchievementSettingsWidget.cpp | 4 ++-- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index fcf4deb237..097fdb9b5d 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -49,7 +49,7 @@ void AchievementManager::Init() m_image_queue.Reset("AchievementManagerImageQueue", [](const std::function& func) { func(); }); if (IsLoggedIn()) - LoginAsync("", [](ResponseType r_type) {}); + Login("", [](ResponseType r_type) {}); INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager Initialized"); } } @@ -64,23 +64,7 @@ void AchievementManager::SetUpdateCallback(UpdateCallback callback) m_update_callback(); } -AchievementManager::ResponseType AchievementManager::Login(const std::string& password) -{ - if (!m_is_runtime_initialized) - { - ERROR_LOG_FMT(ACHIEVEMENTS, "Attempted login (sync) to RetroAchievements server without " - "Achievement Manager initialized."); - return ResponseType::MANAGER_NOT_INITIALIZED; - } - - const ResponseType r_type = VerifyCredentials(password); - FetchBadges(); - - m_update_callback(); - return r_type; -} - -void AchievementManager::LoginAsync(const std::string& password, const ResponseCallback& callback) +void AchievementManager::Login(const std::string& password, const ResponseCallback& callback) { if (!m_is_runtime_initialized) { diff --git a/Source/Core/Core/AchievementManager.h b/Source/Core/Core/AchievementManager.h index 8676544c22..f819610729 100644 --- a/Source/Core/Core/AchievementManager.h +++ b/Source/Core/Core/AchievementManager.h @@ -117,8 +117,7 @@ public: static AchievementManager& GetInstance(); void Init(); void SetUpdateCallback(UpdateCallback callback); - ResponseType Login(const std::string& password); - void LoginAsync(const std::string& password, const ResponseCallback& callback); + void Login(const std::string& password, const ResponseCallback& callback); bool IsLoggedIn() const; void HashGame(const std::string& file_path, const ResponseCallback& callback); void HashGame(const DiscIO::Volume* volume, const ResponseCallback& callback); diff --git a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp index 07ec6fb78f..ec8fde6293 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp +++ b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp @@ -254,9 +254,9 @@ void AchievementSettingsWidget::ToggleRAIntegration() void AchievementSettingsWidget::Login() { Config::SetBaseOrCurrent(Config::RA_USERNAME, m_common_username_input->text().toStdString()); - AchievementManager::GetInstance().Login(m_common_password_input->text().toStdString()); + AchievementManager::GetInstance().Login(m_common_password_input->text().toStdString(), + [](AchievementManager::ResponseType r_type) {}); m_common_password_input->setText(QString()); - m_common_login_failed->setVisible(Config::Get(Config::RA_API_TOKEN).empty()); SaveSettings(); }