From f5d2d9d0ac398afd399f1ebe431a7d9622e2157b Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 4 Jul 2022 11:48:04 -0400 Subject: [PATCH] fix(MessageView): slow chat switching because of height recalculation --- .../Chat/views/ChatMessagesView.qml | 33 --------------- ui/imports/shared/views/chat/MessageView.qml | 42 ++++++++----------- 2 files changed, 18 insertions(+), 57 deletions(-) diff --git a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml index b1da2dff8f..fc04c22ae4 100644 --- a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml @@ -21,7 +21,6 @@ import "../controls" Item { id: root - //anchors.fill: parent property var store property var messageStore @@ -45,19 +44,6 @@ Item { signal openStickerPackPopup(string stickerPackId) signal showReplyArea(string messageId, string author) - property bool allMessagesLoaded: false - - onIsActiveChannelChanged: { - if (!isActiveChannel) { - return - } - // We wait to load all messages, because switching back to chats makes - // the scroll go crazy so it loads way too many messages making it slow - timer.setTimeout(function() { - root.allMessagesLoaded = true - }, 5); - } - Connections { target: root.messageStore.messageModule @@ -107,21 +93,6 @@ Item { } } - Loader { - active: !root.allMessagesLoaded - anchors.centerIn: parent - sourceComponent: Item { - StatusBaseText { - id: loadingText - text: qsTr("Loading...") - } - StatusLoadingIndicator { - anchors.left: loadingText.right - anchors.leftMargin: 8 - } - } - } - ListView { id: chatLogView anchors.top: loadingMessagesIndicator.bottom @@ -273,10 +244,6 @@ Item { delegate: MessageView { id: msgDelegate - // We wait to load all messages, because switching back to chats makes - // the scroll go crazy so it loads way too many messages making it slow - visible: root.allMessagesLoaded - store: root.store messageStore: root.messageStore usersStore: root.usersStore diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index cbc2af5bd9..823906193a 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -10,13 +10,28 @@ import shared.panels.chat 1.0 import shared.views.chat 1.0 import shared.controls.chat 1.0 -Column { +Loader { id: root width: parent.width - anchors.right: !isCurrentUser ? undefined : parent.right z: (typeof chatLogView === "undefined") ? 1 : (chatLogView.count - index) + sourceComponent: { + switch(contentType) { + case Constants.messageContentType.chatIdentifier: + return channelIdentifierComponent + case Constants.messageContentType.fetchMoreMessagesButton: + return fetchMoreMessagesButtonComponent + case Constants.messageContentType.systemMessagePrivateGroupType: + return privateGroupHeaderComponent + case Constants.messageContentType.gapType: + return gapComponent + default: + return compactMessageComponent + + } + } + property var store property var messageStore property var usersStore @@ -212,7 +227,7 @@ Column { // } function startMessageFoundAnimation() { - messageLoader.item.startMessageFoundAnimation(); + root.item.startMessageFoundAnimation(); } ///////////////////////////////////////////// @@ -237,27 +252,6 @@ Column { // } // } - Loader { - id: messageLoader - active: root.visible - width: parent.width - sourceComponent: { - switch(contentType) { - case Constants.messageContentType.chatIdentifier: - return channelIdentifierComponent - case Constants.messageContentType.fetchMoreMessagesButton: - return fetchMoreMessagesButtonComponent - case Constants.messageContentType.systemMessagePrivateGroupType: - return privateGroupHeaderComponent - case Constants.messageContentType.gapType: - return gapComponent - default: - return compactMessageComponent - - } - } - } - Component { id: gapComponent GapComponent {