Always use resolveResource instead of enterRoom or EnterSpaceHome
This commit is contained in:
@@ -230,7 +230,7 @@ QList<ActionsModel::Action> actions{
|
|||||||
}
|
}
|
||||||
auto targetRoom = text.startsWith(QLatin1Char('!')) ? room->connection()->room(text) : room->connection()->roomByAlias(text);
|
auto targetRoom = text.startsWith(QLatin1Char('!')) ? room->connection()->room(text) : room->connection()->roomByAlias(text);
|
||||||
if (targetRoom) {
|
if (targetRoom) {
|
||||||
RoomManager::instance().enterRoom(dynamic_cast<NeoChatRoom *>(targetRoom));
|
RoomManager::instance().resolveResource(targetRoom->id());
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc("Joining room <roomname>.", "Joining room %1.", text));
|
Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc("Joining room <roomname>.", "Joining room %1.", text));
|
||||||
@@ -256,7 +256,7 @@ QList<ActionsModel::Action> actions{
|
|||||||
}
|
}
|
||||||
auto targetRoom = text.startsWith(QLatin1Char('!')) ? room->connection()->room(text) : room->connection()->roomByAlias(text);
|
auto targetRoom = text.startsWith(QLatin1Char('!')) ? room->connection()->room(text) : room->connection()->roomByAlias(text);
|
||||||
if (targetRoom) {
|
if (targetRoom) {
|
||||||
RoomManager::instance().enterRoom(dynamic_cast<NeoChatRoom *>(targetRoom));
|
RoomManager::instance().resolveResource(targetRoom->id());
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc("Knocking room <roomname>.", "Knocking room %1.", text));
|
Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc("Knocking room <roomname>.", "Knocking room %1.", text));
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ void NeoChatConnection::createRoom(const QString &name, const QString &topic, co
|
|||||||
Q_EMIT Controller::instance().errorOccured(i18n("Room creation failed: %1", job->errorString()), {});
|
Q_EMIT Controller::instance().errorOccured(i18n("Room creation failed: %1", job->errorString()), {});
|
||||||
});
|
});
|
||||||
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
|
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
|
||||||
RoomManager::instance().enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
RoomManager::instance().resolveResource(room->id());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ void NeoChatConnection::createSpace(const QString &name, const QString &topic, c
|
|||||||
Q_EMIT Controller::instance().errorOccured(i18n("Space creation failed: %1", job->errorString()), {});
|
Q_EMIT Controller::instance().errorOccured(i18n("Space creation failed: %1", job->errorString()), {});
|
||||||
});
|
});
|
||||||
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
|
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
|
||||||
RoomManager::instance().enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
RoomManager::instance().resolveResource(room->id());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,9 +295,9 @@ void NeoChatConnection::openOrCreateDirectChat(User *user)
|
|||||||
const auto existing = directChats();
|
const auto existing = directChats();
|
||||||
|
|
||||||
if (existing.contains(user)) {
|
if (existing.contains(user)) {
|
||||||
const auto room = static_cast<NeoChatRoom *>(this->room(existing.value(user)));
|
const auto room = this->room(existing.value(user));
|
||||||
if (room) {
|
if (room) {
|
||||||
RoomManager::instance().enterRoom(room);
|
RoomManager::instance().resolveResource(room->id());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ void NotificationsManager::postNotification(NeoChatRoom *room,
|
|||||||
auto connection = dynamic_cast<NeoChatConnection *>(Controller::instance().accounts().get(room->localUser()->id()));
|
auto connection = dynamic_cast<NeoChatConnection *>(Controller::instance().accounts().get(room->localUser()->id()));
|
||||||
Controller::instance().setActiveConnection(connection);
|
Controller::instance().setActiveConnection(connection);
|
||||||
RoomManager::instance().setConnection(connection);
|
RoomManager::instance().setConnection(connection);
|
||||||
RoomManager::instance().enterRoom(room);
|
RoomManager::instance().resolveResource(room->id());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (canReply) {
|
if (canReply) {
|
||||||
@@ -251,7 +251,7 @@ void NotificationsManager::postInviteNotification(NeoChatRoom *rawRoom, const QS
|
|||||||
}
|
}
|
||||||
WindowController::instance().showAndRaiseWindow(notification->xdgActivationToken());
|
WindowController::instance().showAndRaiseWindow(notification->xdgActivationToken());
|
||||||
notification->close();
|
notification->close();
|
||||||
RoomManager::instance().enterRoom(room);
|
RoomManager::instance().resolveResource(room->id());
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto acceptAction = notification->addAction(i18nc("@action:button The thing being accepted is an invitation to chat", "Accept"));
|
const auto acceptAction = notification->addAction(i18nc("@action:button The thing being accepted is an invitation to chat", "Accept"));
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ QQC2.ItemDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: RoomManager.enterRoom(root.currentRoom)
|
onClicked: RoomManager.resolveResource(currentRoom.id)
|
||||||
|
|
||||||
Keys.onEnterPressed: RoomManager.enterRoom(root.currentRoom)
|
Keys.onEnterPressed: RoomManager.resolveResource(currentRoom.id)
|
||||||
Keys.onReturnPressed: RoomManager.enterRoom(root.currentRoom)
|
Keys.onReturnPressed: RoomManager.resolveResource(currentRoom.id)
|
||||||
|
|
||||||
QQC2.ToolTip.visible: text.length > 0 && hovered
|
QQC2.ToolTip.visible: text.length > 0 && hovered
|
||||||
QQC2.ToolTip.text: root.displayName ?? ""
|
QQC2.ToolTip.text: root.displayName ?? ""
|
||||||
|
|||||||
@@ -23,11 +23,7 @@ RowLayout {
|
|||||||
onTriggered: {
|
onTriggered: {
|
||||||
let dialog = pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/ExploreRoomsPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")})
|
let dialog = pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/ExploreRoomsPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")})
|
||||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||||
if (isJoined) {
|
RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, isJoined ? "" : "join")
|
||||||
RoomManager.enterRoom(root.connection.room(roomId))
|
|
||||||
} else {
|
|
||||||
RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, "join")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,11 +54,7 @@ ColumnLayout {
|
|||||||
onTriggered: {
|
onTriggered: {
|
||||||
let dialog = pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/ExploreRoomsPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")})
|
let dialog = pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/ExploreRoomsPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")})
|
||||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||||
if (isJoined) {
|
RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, isJoined ? "" : "join")
|
||||||
RoomManager.enterRoom(root.connection.room(roomId));
|
|
||||||
} else {
|
|
||||||
RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, "join");
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
exploreTabBar.currentIndex = -1;
|
exploreTabBar.currentIndex = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ FormCard.FormCardPage {
|
|||||||
actions: Kirigami.Action {
|
actions: Kirigami.Action {
|
||||||
text: i18n("See older messages…")
|
text: i18n("See older messages…")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
RoomManager.enterRoom(root.connection.room(room.predecessorId));
|
RoomManager.resolveResource(room.predecessorId);
|
||||||
root.close();
|
root.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,7 +387,7 @@ FormCard.FormCardPage {
|
|||||||
actions: Kirigami.Action {
|
actions: Kirigami.Action {
|
||||||
text: i18n("See new room…")
|
text: i18n("See new room…")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
RoomManager.enterRoom(root.connection.room(room.successorId));
|
RoomManager.resolveResource(room.successorId);
|
||||||
root.close();
|
root.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,11 +63,7 @@ Labs.MenuBar {
|
|||||||
onTriggered: {
|
onTriggered: {
|
||||||
let dialog = pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/ExploreRoomsPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")})
|
let dialog = pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/ExploreRoomsPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")})
|
||||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||||
if (isJoined) {
|
RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, isJoined ? "" : "join")
|
||||||
RoomManager.enterRoom(root.connection.room(roomId))
|
|
||||||
} else {
|
|
||||||
RoomManager.resolveResource(roomId, "join")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,11 +59,11 @@ QQC2.Dialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onEnterPressed: {
|
Keys.onEnterPressed: {
|
||||||
RoomManager.enterRoom(roomList.currentItem.currentRoom);
|
RoomManager.resolveResource(roomList.currentItem.currentRoom.id);
|
||||||
root.close();
|
root.close();
|
||||||
}
|
}
|
||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: {
|
||||||
RoomManager.enterRoom(roomList.currentItem.currentRoom);
|
RoomManager.resolveResource(roomList.currentItem.currentRoom.id);
|
||||||
root.close();
|
root.close();
|
||||||
}
|
}
|
||||||
focusSequence: ""
|
focusSequence: ""
|
||||||
@@ -92,23 +92,8 @@ QQC2.Dialog {
|
|||||||
|
|
||||||
delegate: RoomDelegate {
|
delegate: RoomDelegate {
|
||||||
filterText: searchField.text
|
filterText: searchField.text
|
||||||
|
|
||||||
connection: root.connection
|
connection: root.connection
|
||||||
|
onSelected: root.close()
|
||||||
onSelected: {
|
|
||||||
RoomManager.enterRoom(currentRoom);
|
|
||||||
root.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onEnterPressed: {
|
|
||||||
RoomManager.enterRoom(currentRoom);
|
|
||||||
root.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onReturnPressed: {
|
|
||||||
RoomManager.enterRoom(currentRoom);
|
|
||||||
root.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,19 +34,21 @@ Delegates.RoundedItemDelegate {
|
|||||||
signal selected()
|
signal selected()
|
||||||
|
|
||||||
Accessible.name: root.displayName
|
Accessible.name: root.displayName
|
||||||
Accessible.onPressAction: selected()
|
Accessible.onPressAction: select()
|
||||||
Keys.onSpacePressed: selected()
|
|
||||||
Keys.onEnterPressed: selected()
|
|
||||||
|
|
||||||
onPressAndHold: createRoomListContextMenu()
|
onPressAndHold: createRoomListContextMenu()
|
||||||
|
|
||||||
|
Keys.onSpacePressed: select()
|
||||||
|
Keys.onEnterPressed: select()
|
||||||
|
Keys.onReturnPressed: select()
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.RightButton | Qt.LeftButton
|
acceptedButtons: Qt.RightButton | Qt.LeftButton
|
||||||
onTapped: (eventPoint, button) => {
|
onTapped: (eventPoint, button) => {
|
||||||
if (button === Qt.RightButton) {
|
if (button === Qt.RightButton) {
|
||||||
root.createRoomListContextMenu();
|
root.createRoomListContextMenu();
|
||||||
} else {
|
} else {
|
||||||
root.selected();
|
select()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,6 +147,11 @@ Delegates.RoundedItemDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function select() {
|
||||||
|
RoomManager.resolveResource(currentRoom.id);
|
||||||
|
root.selected()
|
||||||
|
}
|
||||||
|
|
||||||
function createRoomListContextMenu() {
|
function createRoomListContextMenu() {
|
||||||
const component = Qt.createComponent("qrc:/org/kde/neochat/qml/ContextMenu.qml")
|
const component = Qt.createComponent("qrc:/org/kde/neochat/qml/ContextMenu.qml")
|
||||||
if (component.status === Component.Error) {
|
if (component.status === Component.Error) {
|
||||||
|
|||||||
@@ -179,11 +179,7 @@ Kirigami.Page {
|
|||||||
title: i18nc("@title", "Explore Rooms")
|
title: i18nc("@title", "Explore Rooms")
|
||||||
})
|
})
|
||||||
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
|
||||||
if (isJoined) {
|
RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, isJoined ? "" : "join")
|
||||||
RoomManager.enterRoom(root.connection.room(roomId))
|
|
||||||
} else {
|
|
||||||
RoomManager.resolveResource(roomId, "join")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -294,11 +290,6 @@ Kirigami.Page {
|
|||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
|
|
||||||
visible: categoryVisible || filterText.length > 0
|
visible: categoryVisible || filterText.length > 0
|
||||||
|
|
||||||
onSelected: RoomManager.enterRoom(currentRoom)
|
|
||||||
|
|
||||||
Keys.onEnterPressed: RoomManager.enterRoom(currentRoom)
|
|
||||||
Keys.onReturnPressed: RoomManager.enterRoom(currentRoom)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ Kirigami.Page {
|
|||||||
target: root.connection
|
target: root.connection
|
||||||
function onJoinedRoom(room, invited) {
|
function onJoinedRoom(room, invited) {
|
||||||
if(root.currentRoom.id === invited.id) {
|
if(root.currentRoom.id === invited.id) {
|
||||||
RoomManager.enterRoom(room);
|
RoomManager.resolveResource(room.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ Item {
|
|||||||
required property NeoChatRoom parentRoom
|
required property NeoChatRoom parentRoom
|
||||||
|
|
||||||
signal createRoom()
|
signal createRoom()
|
||||||
signal enterRoom()
|
|
||||||
|
|
||||||
Delegates.RoundedItemDelegate {
|
Delegates.RoundedItemDelegate {
|
||||||
anchors.centerIn: root
|
anchors.centerIn: root
|
||||||
@@ -146,11 +145,7 @@ Item {
|
|||||||
if (root.isSpace) {
|
if (root.isSpace) {
|
||||||
root.treeView.toggleExpanded(row)
|
root.treeView.toggleExpanded(row)
|
||||||
} else {
|
} else {
|
||||||
if (root.isJoined) {
|
RoomManager.resolveResource(root.roomId, root.isJoined ? "" : "join")
|
||||||
root.enterRoom()
|
|
||||||
} else {
|
|
||||||
RoomManager.resolveResource(root.roomId, "join")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ Kirigami.Page {
|
|||||||
|
|
||||||
delegate: SpaceHierarchyDelegate {
|
delegate: SpaceHierarchyDelegate {
|
||||||
onCreateRoom: _private.createRoom(roomId)
|
onCreateRoom: _private.createRoom(roomId)
|
||||||
onEnterRoom: _private.enterRoom(roomId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,12 +166,5 @@ Kirigami.Page {
|
|||||||
})
|
})
|
||||||
dialog.newChild.connect(childName => {spaceChildrenModel.addPendingChild(childName)})
|
dialog.newChild.connect(childName => {spaceChildrenModel.addPendingChild(childName)})
|
||||||
}
|
}
|
||||||
|
|
||||||
function enterRoom(roomId) {
|
|
||||||
let room = root.currentRoom.connection.room(roomId)
|
|
||||||
if (room) {
|
|
||||||
RoomManager.enterRoom(room)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Loader {
|
|||||||
QQC2.MenuItem {
|
QQC2.MenuItem {
|
||||||
text: i18nc("'Space' is a matrix space", "View Space")
|
text: i18nc("'Space' is a matrix space", "View Space")
|
||||||
icon.name: "view-list-details"
|
icon.name: "view-list-details"
|
||||||
onTriggered: RoomManager.enterSpaceHome(room);
|
onTriggered: RoomManager.resolveResource(room.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
QQC2.MenuItem {
|
QQC2.MenuItem {
|
||||||
@@ -109,7 +109,7 @@ Loader {
|
|||||||
FormCard.FormButtonDelegate {
|
FormCard.FormButtonDelegate {
|
||||||
text: i18nc("'Space' is a matrix space", "View Space")
|
text: i18nc("'Space' is a matrix space", "View Space")
|
||||||
icon.name: "view-list-details"
|
icon.name: "view-list-details"
|
||||||
onClicked: RoomManager.enterRoom(room);
|
onClicked: RoomManager.resolveResource(root.room.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCard.FormButtonDelegate {
|
FormCard.FormButtonDelegate {
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ Kirigami.ApplicationWindow {
|
|||||||
target: root.connection
|
target: root.connection
|
||||||
|
|
||||||
function onDirectChatAvailable(directChat) {
|
function onDirectChatAvailable(directChat) {
|
||||||
RoomManager.enterRoom(root.connection.room(directChat.id));
|
RoomManager.resolveResource(directChat.id);
|
||||||
}
|
}
|
||||||
function onNewKeyVerificationSession(session) {
|
function onNewKeyVerificationSession(session) {
|
||||||
applicationWindow().pageStack.pushDialogLayer(keyVerificationDialogComponent, {
|
applicationWindow().pageStack.pushDialogLayer(keyVerificationDialogComponent, {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ void RoomManager::resolveResource(const QString &idOrUri, const QString &action)
|
|||||||
|
|
||||||
if (uri.type() == Uri::RoomAlias || uri.type() == Uri::RoomId) {
|
if (uri.type() == Uri::RoomAlias || uri.type() == Uri::RoomId) {
|
||||||
connectSingleShot(m_connection, &Connection::newRoom, this, [this, uri](Room *room) {
|
connectSingleShot(m_connection, &Connection::newRoom, this, [this, uri](Room *room) {
|
||||||
enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
resolveResource(room->id());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,82 +191,17 @@ void RoomManager::openRoomForActiveConnection()
|
|||||||
const auto room = qobject_cast<NeoChatRoom *>(m_connection->room(roomId));
|
const auto room = qobject_cast<NeoChatRoom *>(m_connection->room(roomId));
|
||||||
|
|
||||||
if (room) {
|
if (room) {
|
||||||
if (room->isSpace()) {
|
resolveResource(room->id());
|
||||||
enterSpaceHome(room);
|
|
||||||
} else {
|
|
||||||
enterRoom(room);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoomManager::enterRoom(NeoChatRoom *room)
|
|
||||||
{
|
|
||||||
if (m_currentRoom && !m_currentRoom->editCache()->editId().isEmpty()) {
|
|
||||||
m_currentRoom->editCache()->setEditId({});
|
|
||||||
}
|
|
||||||
if (m_currentRoom && m_chatDocumentHandler) {
|
|
||||||
// We're doing these things here because it is critical that they are switched at the same time
|
|
||||||
if (m_chatDocumentHandler->document()) {
|
|
||||||
m_currentRoom->mainCache()->setSavedText(m_chatDocumentHandler->document()->textDocument()->toPlainText());
|
|
||||||
m_chatDocumentHandler->setRoom(room);
|
|
||||||
m_chatDocumentHandler->document()->textDocument()->setPlainText(room->mainCache()->savedText());
|
|
||||||
room->mainCache()->setText(room->mainCache()->savedText());
|
|
||||||
} else {
|
|
||||||
m_chatDocumentHandler->setRoom(room);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_lastCurrentRoom = std::exchange(m_currentRoom, room);
|
|
||||||
Q_EMIT currentRoomChanged();
|
|
||||||
|
|
||||||
if (!m_lastCurrentRoom) {
|
|
||||||
Q_EMIT pushRoom(room, QString());
|
|
||||||
} else {
|
|
||||||
Q_EMIT replaceRoom(m_currentRoom, QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (room && room->timelineSize() == 0) {
|
|
||||||
room->getPreviousContent(20);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save last open room
|
|
||||||
m_lastRoomConfig.writeEntry(m_connection->userId(), room->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RoomManager::openWindow(NeoChatRoom *room)
|
void RoomManager::openWindow(NeoChatRoom *room)
|
||||||
{
|
{
|
||||||
// forward the call to QML
|
// forward the call to QML
|
||||||
Q_EMIT openRoomInNewWindow(room);
|
Q_EMIT openRoomInNewWindow(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoomManager::enterSpaceHome(NeoChatRoom *spaceRoom)
|
|
||||||
{
|
|
||||||
if (!spaceRoom->isSpace()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// If replacing a normal room message timeline make sure any edit is cancelled.
|
|
||||||
if (m_currentRoom && !m_currentRoom->editCache()->editId().isEmpty()) {
|
|
||||||
m_currentRoom->editCache()->setEditId({});
|
|
||||||
}
|
|
||||||
// Save the chatbar text for the current room if any before switching
|
|
||||||
if (m_currentRoom && m_chatDocumentHandler) {
|
|
||||||
if (m_chatDocumentHandler->document()) {
|
|
||||||
m_currentRoom->mainCache()->setSavedText(m_chatDocumentHandler->document()->textDocument()->toPlainText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_lastCurrentRoom = std::exchange(m_currentRoom, spaceRoom);
|
|
||||||
Q_EMIT currentRoomChanged();
|
|
||||||
|
|
||||||
if (!m_lastCurrentRoom) {
|
|
||||||
Q_EMIT pushSpaceHome(spaceRoom);
|
|
||||||
} else {
|
|
||||||
Q_EMIT replaceSpaceHome(m_currentRoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save last open room
|
|
||||||
m_lastRoomConfig.writeEntry(m_connection->userId(), spaceRoom->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
UriResolveResult RoomManager::visitUser(User *user, const QString &action)
|
UriResolveResult RoomManager::visitUser(User *user, const QString &action)
|
||||||
{
|
{
|
||||||
if (action == "mention"_ls || action.isEmpty()) {
|
if (action == "mention"_ls || action.isEmpty()) {
|
||||||
@@ -290,19 +225,46 @@ void RoomManager::visitRoom(Room *room, const QString &eventId)
|
|||||||
auto neoChatRoom = qobject_cast<NeoChatRoom *>(room);
|
auto neoChatRoom = qobject_cast<NeoChatRoom *>(room);
|
||||||
Q_ASSERT(neoChatRoom != nullptr);
|
Q_ASSERT(neoChatRoom != nullptr);
|
||||||
|
|
||||||
|
if (m_currentRoom && !m_currentRoom->editCache()->editId().isEmpty()) {
|
||||||
|
m_currentRoom->editCache()->setEditId({});
|
||||||
|
}
|
||||||
|
if (m_currentRoom && !m_currentRoom->isSpace() && m_chatDocumentHandler) {
|
||||||
|
// We're doing these things here because it is critical that they are switched at the same time
|
||||||
|
if (m_chatDocumentHandler->document()) {
|
||||||
|
m_currentRoom->mainCache()->setSavedText(m_chatDocumentHandler->document()->textDocument()->toPlainText());
|
||||||
|
m_chatDocumentHandler->setRoom(neoChatRoom);
|
||||||
|
m_chatDocumentHandler->document()->textDocument()->setPlainText(neoChatRoom->mainCache()->savedText());
|
||||||
|
neoChatRoom->mainCache()->setText(neoChatRoom->mainCache()->savedText());
|
||||||
|
} else {
|
||||||
|
m_chatDocumentHandler->setRoom(neoChatRoom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_currentRoom) {
|
if (m_currentRoom) {
|
||||||
if (m_currentRoom->id() == room->id()) {
|
if (m_currentRoom->id() == room->id()) {
|
||||||
Q_EMIT goToEvent(eventId);
|
Q_EMIT goToEvent(eventId);
|
||||||
} else {
|
} else {
|
||||||
m_lastCurrentRoom = std::exchange(m_currentRoom, neoChatRoom);
|
m_lastCurrentRoom = std::exchange(m_currentRoom, neoChatRoom);
|
||||||
Q_EMIT currentRoomChanged();
|
Q_EMIT currentRoomChanged();
|
||||||
Q_EMIT replaceRoom(neoChatRoom, eventId);
|
|
||||||
|
if (neoChatRoom->isSpace()) {
|
||||||
|
Q_EMIT replaceSpaceHome(neoChatRoom);
|
||||||
|
} else {
|
||||||
|
Q_EMIT replaceRoom(neoChatRoom, eventId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_lastCurrentRoom = std::exchange(m_currentRoom, neoChatRoom);
|
m_lastCurrentRoom = std::exchange(m_currentRoom, neoChatRoom);
|
||||||
Q_EMIT currentRoomChanged();
|
Q_EMIT currentRoomChanged();
|
||||||
Q_EMIT pushRoom(neoChatRoom, eventId);
|
if (neoChatRoom->isSpace()) {
|
||||||
|
Q_EMIT pushSpaceHome(neoChatRoom);
|
||||||
|
} else {
|
||||||
|
Q_EMIT pushRoom(neoChatRoom, eventId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save last open room
|
||||||
|
m_lastRoomConfig.writeEntry(m_connection->userId(), room->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers)
|
void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers)
|
||||||
@@ -311,7 +273,7 @@ void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAli
|
|||||||
connectSingleShot(job, &Quotient::BaseJob::finished, this, [this, account](Quotient::BaseJob *finish) {
|
connectSingleShot(job, &Quotient::BaseJob::finished, this, [this, account](Quotient::BaseJob *finish) {
|
||||||
if (finish->status() == Quotient::BaseJob::Success) {
|
if (finish->status() == Quotient::BaseJob::Success) {
|
||||||
connectSingleShot(account, &Quotient::Connection::newRoom, this, [this](Quotient::Room *room) {
|
connectSingleShot(account, &Quotient::Connection::newRoom, this, [this](Quotient::Room *room) {
|
||||||
enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
resolveResource(room->id());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Q_EMIT warning(i18n("Failed to join room"), finish->errorString());
|
Q_EMIT warning(i18n("Failed to join room"), finish->errorString());
|
||||||
|
|||||||
@@ -136,13 +136,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE void loadInitialRoom();
|
Q_INVOKABLE void loadInitialRoom();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enter the given room.
|
|
||||||
*
|
|
||||||
* This method will tell NeoChat to open the message list with the given room.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void enterRoom(NeoChatRoom *room);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Open a new window with the given room.
|
* @brief Open a new window with the given room.
|
||||||
*
|
*
|
||||||
@@ -155,13 +148,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE void leaveRoom(NeoChatRoom *room);
|
Q_INVOKABLE void leaveRoom(NeoChatRoom *room);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enter the home page of the given space.
|
|
||||||
*
|
|
||||||
* This method will tell NeoChat to open the home page for the given space.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void enterSpaceHome(NeoChatRoom *spaceRoom);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Knock a room.
|
* @brief Knock a room.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -85,14 +85,7 @@ void Runner::Run(const QString &id, const QString &actionId)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(actionId);
|
Q_UNUSED(actionId);
|
||||||
|
|
||||||
NeoChatRoom *room = qobject_cast<NeoChatRoom *>(roomListModel()->connection()->room(id));
|
RoomManager::instance().resolveResource(id);
|
||||||
|
|
||||||
if (!room) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RoomManager::instance().enterRoom(room);
|
|
||||||
|
|
||||||
WindowController::instance().showAndRaiseWindow(QString());
|
WindowController::instance().showAndRaiseWindow(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user