Compare commits

...

1 Commits

Author SHA1 Message Date
Tobias Fella
d9d5e17be2 Pick libQuotient 0.8 fixes 2023-07-04 22:24:23 +02:00
5 changed files with 29 additions and 18 deletions

View File

@@ -125,18 +125,22 @@ Controller::Controller(QObject *parent)
} }
#endif #endif
#ifdef QUOTIENT_07
connect(&Accounts, &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged);
#else
connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged); connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, &Controller::activeConnectionIndexChanged);
#endif
#ifdef QUOTIENT_07 #ifdef QUOTIENT_07
static int oldAccountCount = 0; static int oldAccountCount = 0;
connect(&AccountRegistry::instance(), &AccountRegistry::accountCountChanged, this, [=]() { connect(&Accounts, &AccountRegistry::accountCountChanged, this, [this]() {
if (AccountRegistry::instance().size() > oldAccountCount) { if (Accounts.size() > oldAccountCount) {
auto connection = AccountRegistry::instance().accounts()[AccountRegistry::instance().size() - 1]; auto connection = Accounts.accounts()[Accounts.size() - 1];
connect(connection, &Connection::syncDone, this, [=]() { connect(connection, &Connection::syncDone, this, [this, connection]() {
handleNotifications(connection); handleNotifications(connection);
}); });
} }
oldAccountCount = AccountRegistry::instance().size(); oldAccountCount = Accounts.size();
}); });
#endif #endif
} }
@@ -277,10 +281,18 @@ void Controller::logout(Connection *conn, bool serverSideLogout)
job.start(); job.start();
loop.exec(); loop.exec();
#ifdef QUOTIENT_07
if (Accounts.count() > 1) {
#else
if (AccountRegistry::instance().count() > 1) { if (AccountRegistry::instance().count() > 1) {
#endif
// Only set the connection if the the account being logged out is currently active // Only set the connection if the the account being logged out is currently active
if (conn == activeConnection()) { if (conn == activeConnection()) {
#ifdef QUOTIENT_07
setActiveConnection(Accounts.accounts()[0]);
#else
setActiveConnection(AccountRegistry::instance().accounts()[0]); setActiveConnection(AccountRegistry::instance().accounts()[0]);
#endif
} }
} else { } else {
setActiveConnection(nullptr); setActiveConnection(nullptr);
@@ -295,8 +307,8 @@ void Controller::addConnection(Connection *c)
{ {
Q_ASSERT_X(c, __FUNCTION__, "Attempt to add a null connection"); Q_ASSERT_X(c, __FUNCTION__, "Attempt to add a null connection");
#ifndef QUOTIENT_07 #ifdef QUOTIENT_07
AccountRegistry::instance().add(c); Accounts.add(c);
#endif #endif
c->setLazyLoading(true); c->setLazyLoading(true);
@@ -548,7 +560,11 @@ NeochatChangePasswordJob::NeochatChangePasswordJob(const QString &newPassword, b
int Controller::accountCount() const int Controller::accountCount() const
{ {
#ifdef QUOTIENT_07
return Accounts.count();
#else
return AccountRegistry::instance().count(); return AccountRegistry::instance().count();
#endif
} }
bool Controller::quitOnLastWindowClosed() bool Controller::quitOnLastWindowClosed()

View File

@@ -43,7 +43,11 @@ void Login::init()
return; return;
} }
#ifdef QUOTIENT_07
m_isLoggedIn = Accounts.isLoggedIn(m_matrixId);
#else
m_isLoggedIn = AccountRegistry::instance().isLoggedIn(m_matrixId); m_isLoggedIn = AccountRegistry::instance().isLoggedIn(m_matrixId);
#endif
Q_EMIT isLoggedInChanged(); Q_EMIT isLoggedInChanged();
if (m_isLoggedIn) { if (m_isLoggedIn) {
return; return;

View File

@@ -63,8 +63,6 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
: Room(connection, std::move(roomId), joinState) : Room(connection, std::move(roomId), joinState)
{ {
connect(connection, &Connection::accountDataChanged, this, &NeoChatRoom::updatePushNotificationState); 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] { connect(this, &Room::fileTransferCompleted, this, [this] {
setFileUploadingProgress(0); setFileUploadingProgress(0);
setHasFileUploading(false); 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() QDateTime NeoChatRoom::lastActiveTime()
{ {
if (timelineSize() == 0) { if (timelineSize() == 0) {

View File

@@ -385,7 +385,6 @@ private:
#endif #endif
private Q_SLOTS: private Q_SLOTS:
void countChanged();
void updatePushNotificationState(QString type); void updatePushNotificationState(QString type);
Q_SIGNALS: Q_SIGNALS:

View File

@@ -249,6 +249,8 @@ Kirigami.ApplicationWindow {
target: Controller target: Controller
function onInitiated() { function onInitiated() {
console.warn("INITIATED")
console.warn(Controller.accountCount)
if (Controller.accountCount === 0) { if (Controller.accountCount === 0) {
pageStack.replace("qrc:/WelcomePage.qml", {}); pageStack.replace("qrc:/WelcomePage.qml", {});
} else if (!roomListLoaded) { } else if (!roomListLoaded) {