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:
@@ -32,10 +32,13 @@ Kirigami.Page {
|
||||
readonly property RoomTreeModel roomTreeModel: RoomTreeModel {
|
||||
connection: root.connection
|
||||
}
|
||||
property bool spaceChanging: false
|
||||
|
||||
readonly property bool collapsed: Config.collapsed
|
||||
|
||||
onCurrentWidthChanged: pageStack.defaultColumnWidth = root.currentWidth
|
||||
Component.onCompleted: pageStack.defaultColumnWidth = root.currentWidth
|
||||
|
||||
|
||||
onCollapsedChanged: {
|
||||
if (collapsed) {
|
||||
sortFilterRoomTreeModel.filterText = "";
|
||||
@@ -87,6 +90,13 @@ Kirigami.Page {
|
||||
|
||||
padding: 0
|
||||
|
||||
Connections {
|
||||
target: RoomManager
|
||||
function onCurrentSpaceChanged() {
|
||||
treeView.expandRecursively();
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
@@ -98,7 +108,6 @@ Kirigami.Page {
|
||||
|
||||
connection: root.connection
|
||||
|
||||
onSelectionChanged: root.spaceChanging = true
|
||||
onSpacesUpdated: sortFilterRoomTreeModel.invalidate()
|
||||
}
|
||||
|
||||
@@ -127,31 +136,14 @@ Kirigami.Page {
|
||||
clip: true
|
||||
reuseItems: false
|
||||
|
||||
onLayoutChanged: {
|
||||
treeView.expandRecursively();
|
||||
if (sortFilterRoomTreeModel.filterTextJustChanged) {
|
||||
sortFilterRoomTreeModel.filterTextJustChanged = false;
|
||||
}
|
||||
if (root.spaceChanging) {
|
||||
if (spaceDrawer.showDirectChats || spaceDrawer.selectedSpaceId.length < 1) {
|
||||
const item = treeView.itemAtIndex(treeView.index(1, 0))
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
RoomManager.resolveResource(item.currentRoom.id);
|
||||
}
|
||||
root.spaceChanging = false;
|
||||
}
|
||||
}
|
||||
|
||||
model: SortFilterRoomTreeModel {
|
||||
id: sortFilterRoomTreeModel
|
||||
|
||||
property bool filterTextJustChanged: false
|
||||
|
||||
sourceModel: root.roomTreeModel
|
||||
activeSpaceId: spaceDrawer.selectedSpaceId
|
||||
mode: spaceDrawer.showDirectChats ? SortFilterRoomTreeModel.DirectChats : SortFilterRoomTreeModel.Rooms
|
||||
activeSpaceId: RoomManager.currentSpace
|
||||
mode: RoomManager.currentSpace === "DM" ? SortFilterRoomTreeModel.DirectChats : SortFilterRoomTreeModel.Rooms
|
||||
onRowsInserted: (index, first, last) => treeView.expandTo(index)
|
||||
onDataChanged: treeView.expandRecursively()
|
||||
}
|
||||
|
||||
selectionModel: ItemSelectionModel {}
|
||||
@@ -334,7 +326,7 @@ Kirigami.Page {
|
||||
|
||||
onTextChanged: newText => {
|
||||
sortFilterRoomTreeModel.filterText = newText;
|
||||
sortFilterRoomTreeModel.filterTextJustChanged = true;
|
||||
treeView.expandRecursively();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user