From d9d5e17be2a2057ab2ee545561fab721cb211f7f Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Tue, 4 Jul 2023 22:24:23 +0200 Subject: [PATCH] Pick libQuotient 0.8 fixes --- src/controller.cpp | 30 +++++++++++++++++++++++------- src/login.cpp | 4 ++++ src/neochatroom.cpp | 10 ---------- src/neochatroom.h | 1 - src/qml/main.qml | 2 ++ 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index b71953fd7..8934e099c 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -125,18 +125,22 @@ Controller::Controller(QObject *parent) } #endif +#ifdef QUOTIENT_07 + connect(&Accounts, &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged); +#else connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged); +#endif #ifdef QUOTIENT_07 static int oldAccountCount = 0; - connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, [=]() { - if (AccountRegistry::instance().size() > oldAccountCount) { - auto connection = AccountRegistry::instance().accounts()[AccountRegistry::instance().size() - 1]; - connect(connection, &Connection::syncDone, this, [=]() { + connect(&Accounts, &AccountRegistry::accountCountChanged, this, [this]() { + if (Accounts.size() > oldAccountCount) { + auto connection = Accounts.accounts()[Accounts.size() - 1]; + connect(connection, &Connection::syncDone, this, [this, connection]() { handleNotifications(connection); }); } - oldAccountCount = AccountRegistry::instance().size(); + oldAccountCount = Accounts.size(); }); #endif } @@ -277,10 +281,18 @@ void Controller::logout(Connection *conn, bool serverSideLogout) job.start(); loop.exec(); +#ifdef QUOTIENT_07 + if (Accounts.count() > 1) { +#else if (AccountRegistry::instance().count() > 1) { +#endif // Only set the connection if the the account being logged out is currently active if (conn == activeConnection()) { +#ifdef QUOTIENT_07 + setActiveConnection(Accounts.accounts()[0]); +#else setActiveConnection(AccountRegistry::instance().accounts()[0]); +#endif } } else { setActiveConnection(nullptr); @@ -295,8 +307,8 @@ void Controller::addConnection(Connection *c) { Q_ASSERT_X(c, __FUNCTION__, "Attempt to add a null connection"); -#ifndef QUOTIENT_07 - AccountRegistry::instance().add(c); +#ifdef QUOTIENT_07 + Accounts.add(c); #endif c->setLazyLoading(true); @@ -548,7 +560,11 @@ NeochatChangePasswordJob::NeochatChangePasswordJob(const QString &newPassword, b int Controller::accountCount() const { +#ifdef QUOTIENT_07 + return Accounts.count(); +#else return AccountRegistry::instance().count(); +#endif } bool Controller::quitOnLastWindowClosed() diff --git a/src/login.cpp b/src/login.cpp index 1121875f9..8b937abaa 100644 --- a/src/login.cpp +++ b/src/login.cpp @@ -43,7 +43,11 @@ void Login::init() return; } +#ifdef QUOTIENT_07 + m_isLoggedIn = Accounts.isLoggedIn(m_matrixId); +#else m_isLoggedIn = AccountRegistry::instance().isLoggedIn(m_matrixId); +#endif Q_EMIT isLoggedInChanged(); if (m_isLoggedIn) { return; diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index bda530045..59afb831d 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -63,8 +63,6 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS : Room(connection, std::move(roomId), joinState) { connect(connection, &Connection::accountDataChanged, this, &NeoChatRoom::updatePushNotificationState); - connect(this, &NeoChatRoom::notificationCountChanged, this, &NeoChatRoom::countChanged); - connect(this, &NeoChatRoom::highlightCountChanged, this, &NeoChatRoom::countChanged); connect(this, &Room::fileTransferCompleted, this, [this] { setFileUploadingProgress(0); setHasFileUploading(false); @@ -339,14 +337,6 @@ void NeoChatRoom::onRedaction(const RoomEvent &prevEvent, const RoomEvent & /*af } } -void NeoChatRoom::countChanged() -{ - if (displayed() && !hasUnreadMessages()) { - resetNotificationCount(); - resetHighlightCount(); - } -} - QDateTime NeoChatRoom::lastActiveTime() { if (timelineSize() == 0) { diff --git a/src/neochatroom.h b/src/neochatroom.h index 6341eb1bb..4dcedbaa1 100644 --- a/src/neochatroom.h +++ b/src/neochatroom.h @@ -385,7 +385,6 @@ private: #endif private Q_SLOTS: - void countChanged(); void updatePushNotificationState(QString type); Q_SIGNALS: diff --git a/src/qml/main.qml b/src/qml/main.qml index 8e8b137b6..120a96d9d 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -249,6 +249,8 @@ Kirigami.ApplicationWindow { target: Controller function onInitiated() { + console.warn("INITIATED") + console.warn(Controller.accountCount) if (Controller.accountCount === 0) { pageStack.replace("qrc:/WelcomePage.qml", {}); } else if (!roomListLoaded) {