mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 07:09:48 -06:00
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).
This commit is contained in:
@ -49,7 +49,7 @@ void AchievementManager::Init()
|
|||||||
m_image_queue.Reset("AchievementManagerImageQueue",
|
m_image_queue.Reset("AchievementManagerImageQueue",
|
||||||
[](const std::function<void()>& func) { func(); });
|
[](const std::function<void()>& func) { func(); });
|
||||||
if (IsLoggedIn())
|
if (IsLoggedIn())
|
||||||
LoginAsync("", [](ResponseType r_type) {});
|
Login("", [](ResponseType r_type) {});
|
||||||
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager Initialized");
|
INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager Initialized");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,23 +64,7 @@ void AchievementManager::SetUpdateCallback(UpdateCallback callback)
|
|||||||
m_update_callback();
|
m_update_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
AchievementManager::ResponseType AchievementManager::Login(const std::string& password)
|
void AchievementManager::Login(const std::string& password, const ResponseCallback& callback)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if (!m_is_runtime_initialized)
|
if (!m_is_runtime_initialized)
|
||||||
{
|
{
|
||||||
|
@ -117,8 +117,7 @@ public:
|
|||||||
static AchievementManager& GetInstance();
|
static AchievementManager& GetInstance();
|
||||||
void Init();
|
void Init();
|
||||||
void SetUpdateCallback(UpdateCallback callback);
|
void SetUpdateCallback(UpdateCallback callback);
|
||||||
ResponseType Login(const std::string& password);
|
void Login(const std::string& password, const ResponseCallback& callback);
|
||||||
void LoginAsync(const std::string& password, const ResponseCallback& callback);
|
|
||||||
bool IsLoggedIn() const;
|
bool IsLoggedIn() const;
|
||||||
void HashGame(const std::string& file_path, const ResponseCallback& callback);
|
void HashGame(const std::string& file_path, const ResponseCallback& callback);
|
||||||
void HashGame(const DiscIO::Volume* volume, const ResponseCallback& callback);
|
void HashGame(const DiscIO::Volume* volume, const ResponseCallback& callback);
|
||||||
|
@ -254,9 +254,9 @@ void AchievementSettingsWidget::ToggleRAIntegration()
|
|||||||
void AchievementSettingsWidget::Login()
|
void AchievementSettingsWidget::Login()
|
||||||
{
|
{
|
||||||
Config::SetBaseOrCurrent(Config::RA_USERNAME, m_common_username_input->text().toStdString());
|
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_password_input->setText(QString());
|
||||||
m_common_login_failed->setVisible(Config::Get(Config::RA_API_TOKEN).empty());
|
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user