From 078f5aab2e1eb1dea30828429069836509551b07 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 30 May 2022 15:24:02 +0200 Subject: Cleanup and reformatting --- lib/accountregistry.cpp | 60 ++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 25 deletions(-) (limited to 'lib/accountregistry.cpp') diff --git a/lib/accountregistry.cpp b/lib/accountregistry.cpp index 9b148b51..b40d5ecf 100644 --- a/lib/accountregistry.cpp +++ b/lib/accountregistry.cpp @@ -79,35 +79,45 @@ void AccountRegistry::invokeLogin() { const auto accounts = SettingsGroup("Accounts").childGroups(); for (const auto& accountId : accounts) { - AccountSettings account{accountId}; + AccountSettings account { accountId }; m_accountsLoading += accountId; emit accountsLoadingChanged(); - if (!account.homeserver().isEmpty()) { - auto accessTokenLoadingJob = loadAccessTokenFromKeychain(account.userId()); - connect(accessTokenLoadingJob, &QKeychain::Job::finished, this, [accountId, this, accessTokenLoadingJob]() { - AccountSettings account{accountId}; - if (accessTokenLoadingJob->error() != QKeychain::Error::NoError) { - emit keychainError(accessTokenLoadingJob->error()); - return; - } - - auto connection = new Connection(account.homeserver()); - connect(connection, &Connection::connected, this, [connection] { - connection->loadState(); - connection->setLazyLoading(true); - - connection->syncLoop(); + if (account.homeserver().isEmpty()) + continue; + + auto accessTokenLoadingJob = + loadAccessTokenFromKeychain(account.userId()); + connect(accessTokenLoadingJob, &QKeychain::Job::finished, this, + [accountId, this, accessTokenLoadingJob]() { + if (accessTokenLoadingJob->error() + != QKeychain::Error::NoError) { + emit keychainError(accessTokenLoadingJob->error()); + return; + } + + AccountSettings account { accountId }; + auto connection = new Connection(account.homeserver()); + connect(connection, &Connection::connected, this, + [connection] { + connection->loadState(); + connection->setLazyLoading(true); + + connection->syncLoop(); + }); + connect(connection, &Connection::loginError, this, + [this, connection](const QString& error, + const QString& details) { + emit loginError(connection, error, details); + }); + connect(connection, &Connection::resolveError, this, + [this, connection](const QString& error) { + emit resolveError(connection, error); + }); + connection->assumeIdentity( + account.userId(), accessTokenLoadingJob->binaryData(), + account.deviceId()); }); - connect(connection, &Connection::loginError, this, [this, connection](const QString& error, const QString& details) { - emit loginError(connection, error, details); - }); - connect(connection, &Connection::resolveError, this, [this, connection](QString error) { - emit resolveError(connection, error); - }); - connection->assumeIdentity(account.userId(), accessTokenLoadingJob->binaryData(), account.deviceId()); - }); - } } } -- cgit v1.2.3