From b9ec33dd947413863969cd3e8fa8c6ad93aa2054 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Sun, 7 Jan 2024 21:25:55 +0100 Subject: [PATCH] Remove activeConnection from Config It's not used anymore --- src/controller.cpp | 19 ++++--------------- src/neochatconfig.kcfg | 3 --- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index d16c10b19..f79a2961d 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -103,7 +103,7 @@ Controller::Controller(QObject *parent) connect(&m_accountRegistry, &AccountRegistry::accountCountChanged, this, [this]() { if (m_accountRegistry.size() > oldAccountCount) { auto connection = dynamic_cast(m_accountRegistry.accounts()[m_accountRegistry.size() - 1]); - connect(connection, &NeoChatConnection::syncDone, this, [this, connection]() { + connect(connection, &NeoChatConnection::syncDone, this, [connection]() { NotificationsManager::instance().handleNotifications(connection); }); connectSingleShot(connection, &NeoChatConnection::syncDone, this, [this, connection] { @@ -143,7 +143,7 @@ void Controller::addConnection(NeoChatConnection *c) c->setLazyLoading(true); - connect(c, &NeoChatConnection::syncDone, this, [this, c] { + connect(c, &NeoChatConnection::syncDone, this, [c] { c->sync(30000); c->saveState(); }); @@ -167,18 +167,13 @@ void Controller::dropConnection(NeoChatConnection *c) void Controller::invokeLogin() { const auto accounts = SettingsGroup("Accounts"_ls).childGroups(); - QString id = NeoChatConfig::self()->activeConnection(); for (const auto &accountId : accounts) { AccountSettings account{accountId}; m_accountsLoading += accountId; Q_EMIT accountsLoadingChanged(); - if (id.isEmpty()) { - // handle case where the account config is empty - id = accountId; - } if (!account.homeserver().isEmpty()) { auto accessTokenLoadingJob = loadAccessTokenFromKeyChain(account); - connect(accessTokenLoadingJob, &QKeychain::Job::finished, this, [accountId, id, this, accessTokenLoadingJob](QKeychain::Job *) { + connect(accessTokenLoadingJob, &QKeychain::Job::finished, this, [accountId, this, accessTokenLoadingJob](QKeychain::Job *) { AccountSettings account{accountId}; QString accessToken; if (accessTokenLoadingJob->error() == QKeychain::Error::NoError) { @@ -188,14 +183,11 @@ void Controller::invokeLogin() } auto connection = new NeoChatConnection(account.homeserver()); - connect(connection, &NeoChatConnection::connected, this, [this, connection, id] { + connect(connection, &NeoChatConnection::connected, this, [this, connection] { connection->loadState(); addConnection(connection); m_accountsLoading.removeAll(connection->userId()); Q_EMIT accountsLoadingChanged(); - if (connection->userId() == id) { - setActiveConnection(connection); - } }); connect(connection, &NeoChatConnection::loginError, this, [this, connection](const QString &error, const QString &) { if (error == "Unrecognised access token"_ls) { @@ -318,14 +310,11 @@ void Controller::setActiveConnection(NeoChatConnection *connection) } m_connection = connection; if (connection != nullptr) { - NeoChatConfig::self()->setActiveConnection(connection->userId()); connect(connection, &NeoChatConnection::requestFailed, this, [](BaseJob *job) { if (dynamic_cast(job) && job->jsonData()["errcode"_ls].toString() == "M_TOO_LARGE"_ls) { RoomManager::instance().warning(i18n("File too large to download."), i18n("Contact your matrix server administrator for support.")); } }); - } else { - NeoChatConfig::self()->setActiveConnection(QString()); } NeoChatConfig::self()->save(); Q_EMIT activeConnectionChanged(); diff --git a/src/neochatconfig.kcfg b/src/neochatconfig.kcfg index 52df68e8d..ee592333f 100644 --- a/src/neochatconfig.kcfg +++ b/src/neochatconfig.kcfg @@ -11,9 +11,6 @@ - - -