diff options
| author | LillyJadeKatrin <lilly.kitty.1988@gmail.com> | 2024-03-18 16:33:37 -0400 |
|---|---|---|
| committer | LillyJadeKatrin <lilly.kitty.1988@gmail.com> | 2024-05-01 06:43:18 -0400 |
| commit | 7b3fac18cd8073db97df5673c41ee72288b2e493 (patch) | |
| tree | 4f7fc35b3abeb299c887430c2d29d60b6d4a432f /Source | |
| parent | ba519e4670b4e85df1ae03ba9474dd4f52f39343 (diff) | |
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).
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/AchievementManager.cpp | 20 | ||||
| -rw-r--r-- | Source/Core/Core/AchievementManager.h | 3 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Achievements/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<void()>& 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(); } |
