Delay members loading for faster room switching

This commit is contained in:
miruka 2020-09-13 15:46:58 -04:00
parent 6df9647b59
commit 9b1608b696
3 changed files with 21 additions and 2 deletions

View File

@ -110,6 +110,8 @@ ListView {
// https://doc.qt.io/qt-5/qml-qtquick-viewtransition.html // https://doc.qt.io/qt-5/qml-qtquick-viewtransition.html
// #handling-interrupted-animations // #handling-interrupted-animations
populate: add
add: Transition { add: Transition {
// ScriptAction { script: if (listView.debug) print("add") } // ScriptAction { script: if (listView.debug) print("add") }
HNumberAnimation { property: "opacity"; from: 0; to: 1 } HNumberAnimation { property: "opacity"; from: 0; to: 1 }

View File

@ -15,6 +15,8 @@ HLoader {
property var history: [] property var history: []
property int historyLength: 20 property int historyLength: 20
readonly property alias appearAnimation: appearAnimation
signal aboutToRecycle() signal aboutToRecycle()
signal recycled() signal recycled()
signal previousShown(string componentUrl, var properties) signal previousShown(string componentUrl, var properties)

View File

@ -34,8 +34,6 @@ HColumnLayout {
id: memberList id: memberList
clip: true clip: true
model: ModelStore.get(modelSyncId)
delegate: MemberDelegate { delegate: MemberDelegate {
id: member id: member
width: memberList.width width: memberList.width
@ -69,6 +67,22 @@ HColumnLayout {
Keys.onMenuPressed: Keys.onMenuPressed:
if (currentItem) currentItem.doRightClick(false) 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 Layout.fillWidth: true
@ -102,6 +116,7 @@ HColumnLayout {
onTextChanged: { onTextChanged: {
stackView.pop(stackView.initialItem) stackView.pop(stackView.initialItem)
if (! stackView.currentItem.model) return
py.callCoro("set_string_filter", [modelSyncId, text]) py.callCoro("set_string_filter", [modelSyncId, text])
} }