fix(MessageView): slow chat switching because of height recalculation

This commit is contained in:
Jonathan Rainville 2022-07-04 11:48:04 -04:00
parent 963374502b
commit f5d2d9d0ac
2 changed files with 18 additions and 57 deletions

View File

@ -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

View File

@ -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 {