diff --git a/src/neochatconnection.cpp b/src/neochatconnection.cpp index cd15f366e..98cefd4de 100644 --- a/src/neochatconnection.cpp +++ b/src/neochatconnection.cpp @@ -11,7 +11,6 @@ #include "neochatconfig.h" #include "neochatroom.h" #include "notificationsmanager.h" -#include "roommanager.h" #include "spacehierarchycache.h" #include @@ -80,10 +79,9 @@ void NeoChatConnection::connectSignals() Q_EMIT userConsentRequired(job->errorUrl()); } }); - connect(this, &NeoChatConnection::requestFailed, this, [](BaseJob *job) { + connect(this, &NeoChatConnection::requestFailed, this, [this](BaseJob *job) { if (dynamic_cast(job) && job->jsonData()["errcode"_ls].toString() == "M_TOO_LARGE"_ls) { - RoomManager::instance().showMessage(MessageType::Warning, - i18n("File too large to download.
Contact your matrix server administrator for support.")); + Q_EMIT showMessage(MessageType::Warning, i18n("File too large to download.
Contact your matrix server administrator for support.")); } }); connect(this, &NeoChatConnection::directChatsListChanged, this, [this](DirectChatsMap additions, DirectChatsMap removals) { @@ -347,14 +345,6 @@ void NeoChatConnection::createRoom(const QString &name, const QString &topic, co connect(job, &CreateRoomJob::failure, this, [this, job] { Q_EMIT errorOccured(i18n("Room creation failed: %1", job->errorString())); }); - connect( - this, - &Connection::newRoom, - this, - [](Room *room) { - RoomManager::instance().resolveResource(room->id()); - }, - Qt::SingleShotConnection); } void NeoChatConnection::createSpace(const QString &name, const QString &topic, const QString &parent, bool setChildParent) @@ -384,14 +374,6 @@ void NeoChatConnection::createSpace(const QString &name, const QString &topic, c connect(job, &CreateRoomJob::failure, this, [this, job] { Q_EMIT errorOccured(i18n("Space creation failed: %1", job->errorString())); }); - connect( - this, - &Connection::newRoom, - this, - [](Room *room) { - RoomManager::instance().resolveResource(room->id()); - }, - Qt::SingleShotConnection); } bool NeoChatConnection::directChatExists(Quotient::User *user) diff --git a/src/neochatconnection.h b/src/neochatconnection.h index dafbf222f..44724d2df 100644 --- a/src/neochatconnection.h +++ b/src/neochatconnection.h @@ -14,6 +14,7 @@ #include #endif +#include "enums/messagetype.h" #include "linkpreviewer.h" #include "models/threepidmodel.h" @@ -198,6 +199,11 @@ Q_SIGNALS: void badgeNotificationCountChanged(NeoChatConnection *connection, int count); void canCheckMutualRoomsChanged(); + /** + * @brief Request a message be shown to the user of the given type. + */ + void showMessage(MessageType::Type messageType, const QString &message); + /** * @brief Request a error message be shown to the user. */ diff --git a/src/roommanager.cpp b/src/roommanager.cpp index 20e27125a..7db1da4b4 100644 --- a/src/roommanager.cpp +++ b/src/roommanager.cpp @@ -445,6 +445,10 @@ void RoomManager::setConnection(NeoChatConnection *connection) m_connection = connection; if (m_connection != nullptr) { + connect(m_connection, &NeoChatConnection::showMessage, this, &RoomManager::showMessage); + connect(m_connection, &NeoChatConnection::createdRoom, this, [this](Quotient::Room *room) { + resolveResource(room->id()); + }); connect(m_connection, &NeoChatConnection::directChatAvailable, this, [this](Quotient::Room *directChat) { resolveResource(directChat->id()); });