Load Chat faster by delaying EventList loading

This commit is contained in:
miruka 2020-03-11 12:53:55 -04:00
parent 8a43690676
commit b26fe10810
4 changed files with 36 additions and 9 deletions

View File

@ -37,6 +37,8 @@ HLoader {
property var history: [] property var history: []
property int historyLength: 20 property int historyLength: 20
readonly property alias appearAnimation: appearAnimation
function _show(componentUrl, properties={}) { function _show(componentUrl, properties={}) {
history.unshift([componentUrl, properties]) history.unshift([componentUrl, properties])
@ -89,6 +91,6 @@ HLoader {
from: -300 from: -300
to: 0 to: 0
easing.type: Easing.OutBack easing.type: Easing.OutBack
duration: theme.animationDuration * 2 duration: theme.animationDuration * 1.5
} }
} }

View File

@ -54,8 +54,9 @@ Item {
width: 96 * theme.uiScale width: 96 * theme.uiScale
height: width height: width
source: opacity > 0 ? "../../Base/HBusyIndicator.qml" : "" source: "../../Base/HBusyIndicator.qml"
opacity: ready ? 0 : 1 active: ready ? 0 : 1
opacity: active ? 1 : 0
Behavior on opacity { HNumberAnimation { factor: 2 } } Behavior on opacity { HNumberAnimation { factor: 2 } }
} }

View File

@ -17,18 +17,38 @@ HColumnPage {
readonly property alias composer: composer readonly property alias composer: composer
readonly property bool loadEventList: ! pageLoader.appearAnimation.running
RoomHeader { RoomHeader {
Layout.fillWidth: true Layout.fillWidth: true
} }
EventList { Timer {
id: eventList id: delayEventListLoadingTimer
interval: 150
running: true
}
HLoader {
id: eventListLoader
sourceComponent: loadEventList ? evListComponent : placeholder
opacity: loadEventList ? 1 : 0
// Avoid a certain binding loop
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Behavior on opacity { HNumberAnimation {} }
Component {
id: placeholder
Item {}
}
Component {
id: evListComponent
EventList {}
}
} }
TypingMembersBar { TypingMembersBar {
@ -60,8 +80,9 @@ HColumnPage {
Composer { Composer {
id: composer id: composer
visible: ! chat.roomInfo.left && eventList: loadEventList ? eventListLoader.item : null
! chat.roomInfo.inviter_id visible:
! chat.roomInfo.left && ! chat.roomInfo.inviter_id
} }
} }

View File

@ -18,6 +18,8 @@ Rectangle {
Layout.maximumHeight: pageLoader.height / 2 Layout.maximumHeight: pageLoader.height / 2
property Item eventList
property string indent: " " property string indent: " "
property var aliases: window.settings.writeAliases property var aliases: window.settings.writeAliases
@ -150,7 +152,7 @@ Rectangle {
} }
} }
area.onSelectedTextChanged: if (area.selectedText) { area.onSelectedTextChanged: if (area.selectedText && eventList) {
eventList.selectableLabelContainer.clearSelection() eventList.selectableLabelContainer.clearSelection()
} }
@ -192,6 +194,7 @@ Rectangle {
area.Keys.onPressed.connect(ev => { area.Keys.onPressed.connect(ev => {
if (ev.matches(StandardKey.Copy) && if (ev.matches(StandardKey.Copy) &&
eventList &&
eventList.selectableLabelContainer.joinedSelection eventList.selectableLabelContainer.joinedSelection
) { ) {
ev.accepted = true ev.accepted = true