Move room management from Controller to RoomManager
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <QStringBuilder>
|
||||
|
||||
#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<NeoChatRoom *>(room));
|
||||
});
|
||||
}
|
||||
Q_EMIT connectionChanged();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user