Fix layoutTimer

Only change the room when a space is change rather than on all layout refreshes
This commit is contained in:
James Graham
2024-02-05 17:48:04 +00:00
parent 2895b7bc21
commit 367131d64c
2 changed files with 10 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ Kirigami.Page {
readonly property RoomListModel roomListModel: RoomListModel { readonly property RoomListModel roomListModel: RoomListModel {
connection: root.connection connection: root.connection
} }
property bool spaceChanging: false
readonly property bool collapsed: Config.collapsed readonly property bool collapsed: Config.collapsed
@@ -106,6 +107,7 @@ Kirigami.Page {
connection: root.connection connection: root.connection
onSelectionChanged: root.spaceChanging = true;
onSpacesUpdated: sortFilterRoomListModel.invalidate() onSpacesUpdated: sortFilterRoomListModel.invalidate()
} }
@@ -218,9 +220,10 @@ Kirigami.Page {
// in this case activeSpaceId followed by mode. // in this case activeSpaceId followed by mode.
Timer { Timer {
id: layoutTimer id: layoutTimer
interval: 100 interval: 300
onTriggered: if (spaceDrawer.showDirectChats || spaceDrawer.selectedSpaceId.length < 1) { onTriggered: if ((spaceDrawer.showDirectChats || spaceDrawer.selectedSpaceId.length < 1) && root.spaceChanging) {
RoomManager.resolveResource(listView.itemAtIndex(0).currentRoom.id) RoomManager.resolveResource(listView.itemAtIndex(0).currentRoom.id);
root.spaceChanging = false;
} }
} }

View File

@@ -25,6 +25,7 @@ QQC2.Control {
property bool showDirectChats: false property bool showDirectChats: false
signal selectionChanged()
signal spacesUpdated() signal spacesUpdated()
contentItem: Loader { contentItem: Loader {
@@ -94,6 +95,7 @@ QQC2.Control {
onClicked: { onClicked: {
root.showDirectChats = false root.showDirectChats = false
root.selectedSpaceId = "" root.selectedSpaceId = ""
root.selectionChanged()
} }
} }
AvatarTabButton { AvatarTabButton {
@@ -113,6 +115,7 @@ QQC2.Control {
onClicked: { onClicked: {
root.showDirectChats = true root.showDirectChats = true
root.selectedSpaceId = "" root.selectedSpaceId = ""
root.selectionChanged()
} }
QQC2.Label { QQC2.Label {
@@ -176,6 +179,7 @@ QQC2.Control {
RoomManager.resolveResource(currentRoom.id) RoomManager.resolveResource(currentRoom.id)
} }
root.selectedSpaceId = roomId root.selectedSpaceId = roomId
root.selectionChanged()
} }
checked: root.selectedSpaceId === roomId checked: root.selectedSpaceId === roomId
onContextMenuRequested: root.createContextMenu(currentRoom) onContextMenuRequested: root.createContextMenu(currentRoom)