From b26fe108102936bfed4b492c315f7d5e99d6ab0b Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 11 Mar 2020 12:53:55 -0400 Subject: [PATCH] Load Chat faster by delaying EventList loading --- src/gui/PageLoader.qml | 4 +++- src/gui/Pages/Chat/Chat.qml | 5 +++-- src/gui/Pages/Chat/ChatPage.qml | 31 ++++++++++++++++++++++++++----- src/gui/Pages/Chat/Composer.qml | 5 ++++- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/gui/PageLoader.qml b/src/gui/PageLoader.qml index 527ce163..52c7caad 100644 --- a/src/gui/PageLoader.qml +++ b/src/gui/PageLoader.qml @@ -37,6 +37,8 @@ HLoader { property var history: [] property int historyLength: 20 + readonly property alias appearAnimation: appearAnimation + function _show(componentUrl, properties={}) { history.unshift([componentUrl, properties]) @@ -89,6 +91,6 @@ HLoader { from: -300 to: 0 easing.type: Easing.OutBack - duration: theme.animationDuration * 2 + duration: theme.animationDuration * 1.5 } } diff --git a/src/gui/Pages/Chat/Chat.qml b/src/gui/Pages/Chat/Chat.qml index efe675d7..3f666839 100644 --- a/src/gui/Pages/Chat/Chat.qml +++ b/src/gui/Pages/Chat/Chat.qml @@ -54,8 +54,9 @@ Item { width: 96 * theme.uiScale height: width - source: opacity > 0 ? "../../Base/HBusyIndicator.qml" : "" - opacity: ready ? 0 : 1 + source: "../../Base/HBusyIndicator.qml" + active: ready ? 0 : 1 + opacity: active ? 1 : 0 Behavior on opacity { HNumberAnimation { factor: 2 } } } diff --git a/src/gui/Pages/Chat/ChatPage.qml b/src/gui/Pages/Chat/ChatPage.qml index 985971da..1ef7f4d6 100644 --- a/src/gui/Pages/Chat/ChatPage.qml +++ b/src/gui/Pages/Chat/ChatPage.qml @@ -17,18 +17,38 @@ HColumnPage { readonly property alias composer: composer + readonly property bool loadEventList: ! pageLoader.appearAnimation.running RoomHeader { Layout.fillWidth: true } - EventList { - id: eventList + Timer { + 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.fillHeight: true + + Behavior on opacity { HNumberAnimation {} } + + Component { + id: placeholder + Item {} + } + + Component { + id: evListComponent + EventList {} + } } TypingMembersBar { @@ -60,8 +80,9 @@ HColumnPage { Composer { id: composer - visible: ! chat.roomInfo.left && - ! chat.roomInfo.inviter_id + eventList: loadEventList ? eventListLoader.item : null + visible: + ! chat.roomInfo.left && ! chat.roomInfo.inviter_id } } diff --git a/src/gui/Pages/Chat/Composer.qml b/src/gui/Pages/Chat/Composer.qml index 9e776c5a..3005a5ce 100644 --- a/src/gui/Pages/Chat/Composer.qml +++ b/src/gui/Pages/Chat/Composer.qml @@ -18,6 +18,8 @@ Rectangle { Layout.maximumHeight: pageLoader.height / 2 + property Item eventList + property string indent: " " 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() } @@ -192,6 +194,7 @@ Rectangle { area.Keys.onPressed.connect(ev => { if (ev.matches(StandardKey.Copy) && + eventList && eventList.selectableLabelContainer.joinedSelection ) { ev.accepted = true