From 9b1608b6962010e75899a555c7fa88b2ee61ebc3 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 13 Sep 2020 15:46:58 -0400 Subject: [PATCH] Delay members loading for faster room switching --- src/gui/Base/HListView.qml | 2 ++ src/gui/PageLoader.qml | 2 ++ .../Chat/RoomPane/MemberView/MemberView.qml | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/Base/HListView.qml b/src/gui/Base/HListView.qml index 2cec4317..3ea29bca 100644 --- a/src/gui/Base/HListView.qml +++ b/src/gui/Base/HListView.qml @@ -110,6 +110,8 @@ ListView { // https://doc.qt.io/qt-5/qml-qtquick-viewtransition.html // #handling-interrupted-animations + populate: add + add: Transition { // ScriptAction { script: if (listView.debug) print("add") } HNumberAnimation { property: "opacity"; from: 0; to: 1 } diff --git a/src/gui/PageLoader.qml b/src/gui/PageLoader.qml index e0445cb5..be761a07 100644 --- a/src/gui/PageLoader.qml +++ b/src/gui/PageLoader.qml @@ -15,6 +15,8 @@ HLoader { property var history: [] property int historyLength: 20 + readonly property alias appearAnimation: appearAnimation + signal aboutToRecycle() signal recycled() signal previousShown(string componentUrl, var properties) diff --git a/src/gui/Pages/Chat/RoomPane/MemberView/MemberView.qml b/src/gui/Pages/Chat/RoomPane/MemberView/MemberView.qml index 777b3424..1d640b88 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberView/MemberView.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberView/MemberView.qml @@ -34,8 +34,6 @@ HColumnLayout { id: memberList clip: true - model: ModelStore.get(modelSyncId) - delegate: MemberDelegate { id: member width: memberList.width @@ -69,6 +67,22 @@ HColumnLayout { Keys.onMenuPressed: if (currentItem) currentItem.doRightClick(false) + + Timer { + id: updateModelTimer + interval: pageLoader.appearAnimation.duration + running: true + onTriggered: memberList.model = ModelStore.get(modelSyncId) + } + + Connections { + target: pageLoader + + function onRecycled() { + memberList.model = null + updateModelTimer.restart() + } + } } Layout.fillWidth: true @@ -102,6 +116,7 @@ HColumnLayout { onTextChanged: { stackView.pop(stackView.initialItem) + if (! stackView.currentItem.model) return py.callCoro("set_string_filter", [modelSyncId, text]) }