diff --git a/qml/main.qml b/qml/main.qml index c97d42edf..ad6a24df3 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -289,18 +289,10 @@ Kirigami.ApplicationWindow { root.showWindow() } - function onOpenRoom(room) { - RoomManager.enterRoom(room) - } - function onUserConsentRequired(url) { consentSheet.url = url consentSheet.open() } - - function onRoomJoined(roomName) { - RoomManager.enterRoom(Controller.activeConnection.room(roomName)) - } } Connections { diff --git a/src/actionshandler.cpp b/src/actionshandler.cpp index f1ef574ab..9714481e3 100644 --- a/src/actionshandler.cpp +++ b/src/actionshandler.cpp @@ -12,6 +12,7 @@ #include #include "controller.h" +#include "roommanager.h" ActionsHandler::ActionsHandler(QObject *parent) : QObject(parent) @@ -52,7 +53,7 @@ void ActionsHandler::setConnection(Connection *connection) if (m_connection != nullptr) { connect(m_connection, &Connection::directChatAvailable, this, [this](Quotient::Room *room) { room->setDisplayed(true); - Q_EMIT Controller::instance().roomJoined(room->id()); + RoomManager::instance().enterRoom(qobject_cast(room)); }); } Q_EMIT connectionChanged(); diff --git a/src/controller.cpp b/src/controller.cpp index 5bd53dd72..baf8b5b77 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -567,9 +567,6 @@ void Controller::createRoom(const QString &name, const QString &topic) Quotient::CreateRoomJob::connect(createRoomJob, &CreateRoomJob::failure, [=] { Q_EMIT errorOccured(i18n("Room creation failed: \"%1\"", createRoomJob->errorString())); }); - Quotient::CreateRoomJob::connect(createRoomJob, &CreateRoomJob::success, [=] { - Q_EMIT roomJoined(createRoomJob->roomId()); - }); } bool Controller::isOnline() const diff --git a/src/controller.h b/src/controller.h index f6263abcf..55cd0ce25 100644 --- a/src/controller.h +++ b/src/controller.h @@ -105,13 +105,6 @@ Q_SIGNALS: /// Error occurred because of user inputs void errorOccured(const QString &error); - /// \brief Emitted when an action made the user join a room. - /// - /// Either when a new room was created, a direct chat was started - /// or a group chat was joined. The UI will react to this signal - /// and switch to the newly joined room. - void roomJoined(const QString &room); - /// Error occurred because of server or bug in NeoChat void globalErrorOccured(QString error, QString detail); void syncDone(); @@ -126,7 +119,6 @@ Q_SIGNALS: void aboutDataChanged(); void passwordStatus(Controller::PasswordStatus _t1); void showWindow(); - void openRoom(NeoChatRoom *room); void userConsentRequired(QUrl url); void testConnectionResult(const QString &connection, bool usable); void isOnlineChanged(bool isOnline); diff --git a/src/notificationsmanager.cpp b/src/notificationsmanager.cpp index 845c17ec9..85e3e5fc8 100644 --- a/src/notificationsmanager.cpp +++ b/src/notificationsmanager.cpp @@ -16,6 +16,7 @@ #endif #include "controller.h" +#include "roommanager.h" #include "neochatconfig.h" NotificationsManager &NotificationsManager::instance() @@ -55,7 +56,7 @@ void NotificationsManager::postNotification(NeoChatRoom *room, notification->setDefaultAction(i18n("Open NeoChat in this room")); connect(notification, &KNotification::defaultActivated, this, [this, room]() { - Q_EMIT Controller::instance().openRoom(room); + Q_EMIT RoomManager::instance().enterRoom(room); Q_EMIT Controller::instance().showWindow(); }); diff --git a/src/roommanager.cpp b/src/roommanager.cpp index c6715df2c..4228ef04c 100644 --- a/src/roommanager.cpp +++ b/src/roommanager.cpp @@ -191,7 +191,8 @@ void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers) { - // We already listen to roomJoined signal in the Controller + // This should trigger a signal in Quotient once done and NeoChat will + // react to it and open the newly joined room. account->joinRoom(QUrl::toPercentEncoding(roomAliasOrId), viaServers); }