Rework roommanager for improved stability

Fixes #645

- Active space handling is moved from QML to RoomManager
- Active tab in SpaceDrawer (space / no space / DM) is unified in a single variable
- RoomList & RoomPage loading is simplified: We're always pushing a RoomPage now; if there is no room, a placeholder is shown
- SpaceHomePage is moved into RoomPage; This replaces the entire push/replace room/spacehome logic
- If the current room is a space, the space home is shown, otherwise the timeline
- The concept of "previous room" is removed entirely. If we're leaving the active room, the placeholder room page is shown
- When clicking on a space in the list, the space room list is switched and the space home page is shown

In short, these changes should (after some initial regressions) lead to a less crashy NeoChat :)
This commit is contained in:
Tobias Fella
2024-03-29 23:23:28 +01:00
parent eaf4663c84
commit b75dbe8d5c
8 changed files with 315 additions and 430 deletions

View File

@@ -72,7 +72,7 @@ Kirigami.Page {
/// Disable cancel shortcut. Used by the separate window since it provides its own cancel implementation.
property bool disableCancelShortcut: false
title: root.currentRoom.displayName
title: root.currentRoom ? root.currentRoom.displayName : ""
focus: true
padding: 0
@@ -116,7 +116,7 @@ Kirigami.Page {
Loader {
id: timelineViewLoader
anchors.fill: parent
active: root.currentRoom && !root.currentRoom.isInvite && !root.loading
active: root.currentRoom && !root.currentRoom.isInvite && !root.loading && !root.currentRoom.isSpace
sourceComponent: TimelineView {
id: timelineView
currentRoom: root.currentRoom
@@ -143,7 +143,23 @@ Kirigami.Page {
}
Loader {
active: root.loading && !invitationLoader.active
id: spaceLoader
active: root.currentRoom && root.currentRoom.isSpace
anchors.fill: parent
sourceComponent: SpaceHomePage {}
}
Loader {
active: !RoomManager.currentRoom
anchors.centerIn: parent
sourceComponent: Kirigami.PlaceholderMessage {
icon.name: "org.kde.neochat"
text: i18n("Welcome to NeoChat")
}
}
Loader {
active: root.loading && !invitationLoader.active && RoomManager.currentRoom && !spaceLoader.active
anchors.centerIn: parent
sourceComponent: Kirigami.LoadingPlaceholder {
anchors.centerIn: parent
@@ -176,11 +192,7 @@ Kirigami.Page {
Connections {
target: RoomManager
function onCurrentRoomChanged() {
if (!RoomManager.currentRoom) {
if (pageStack.lastItem === root) {
pageStack.pop();
}
} else if (root.currentRoom.isInvite) {
if (root.currentRoom && root.currentRoom.isInvite) {
root.currentRoom.clearInvitationNotification();
}
}
@@ -188,6 +200,10 @@ Kirigami.Page {
function onWarning(title, message) {
root.warning(title, message);
}
function onGoToEvent(eventId) {
(timelineViewLoader.item as TimelineView).goToEvent(eventId);
}
}
Shortcut {