1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Async WritePassword hates me

This commit is contained in:
Joshua Goins 2023-12-20 21:52:43 -05:00
parent 322885e8e8
commit 167a94a2fe
2 changed files with 7 additions and 9 deletions

View file

@ -106,7 +106,7 @@ private:
/* /*
* Sets a value in the keychain. This function is asynchronous. * Sets a value in the keychain. This function is asynchronous.
*/ */
QCoro::Task<> setKeychainValue(const QString &key, const QString &value); void setKeychainValue(const QString &key, const QString &value);
/* /*
* Retrieves a value from the keychain. This function is synchronous. * Retrieves a value from the keychain. This function is synchronous.

View file

@ -269,7 +269,7 @@ void Account::fetchAvatar()
} }
} }
QCoro::Task<> Account::setKeychainValue(const QString &key, const QString &value) void Account::setKeychainValue(const QString &key, const QString &value)
{ {
auto job = new QKeychain::WritePasswordJob(QStringLiteral("Astra"), this); auto job = new QKeychain::WritePasswordJob(QStringLiteral("Astra"), this);
job->setTextData(value); job->setTextData(value);
@ -281,13 +281,11 @@ QCoro::Task<> Account::setKeychainValue(const QString &key, const QString &value
job->setInsecureFallback(m_launcher.isSteamDeck()); // The Steam Deck does not have secrets provider in Game Mode job->setInsecureFallback(m_launcher.isSteamDeck()); // The Steam Deck does not have secrets provider in Game Mode
job->start(); job->start();
co_await qCoro(job, &QKeychain::WritePasswordJob::finished); connect(job, &QKeychain::WritePasswordJob::finished, this, [job] {
if (job->error() != QKeychain::NoError) {
if (job->error() != QKeychain::NoError) { qWarning(ASTRA_LOG) << "Error when writing" << job->errorString();
qWarning(ASTRA_LOG) << "Error when writing" << key << job->errorString(); }
} });
co_return;
} }
QCoro::Task<QString> Account::getKeychainValue(const QString &key) QCoro::Task<QString> Account::getKeychainValue(const QString &key)