fix(chat): load as much messages as view requires

fixes: #10221
This commit is contained in:
Patryk Osmaczko 2023-04-06 19:39:13 +02:00 committed by osmaczko
parent 4a92405444
commit 65415ef34b
1 changed files with 10 additions and 2 deletions

View File

@ -50,7 +50,7 @@ Item {
readonly property bool isMostRecentMessageInViewport: chatLogView.visibleArea.yPosition >= 0.999 - chatLogView.visibleArea.heightRatio readonly property bool isMostRecentMessageInViewport: chatLogView.visibleArea.yPosition >= 0.999 - chatLogView.visibleArea.heightRatio
readonly property var chatDetails: chatContentModule.chatDetails || null readonly property var chatDetails: chatContentModule.chatDetails || null
readonly property var loadMoreMessagesIfScrollBelowThreshold: Backpressure.oneInTime(root, 100, function() { readonly property var loadMoreMessagesIfScrollBelowThreshold: Backpressure.oneInTimeQueued(root, 100, function() {
if(scrollY < 1000) messageStore.loadMoreMessages() if(scrollY < 1000) messageStore.loadMoreMessages()
}) })
@ -200,7 +200,15 @@ Item {
d.loadMoreMessagesIfScrollBelowThreshold() d.loadMoreMessagesIfScrollBelowThreshold()
} }
onCountChanged: d.markAllMessagesReadIfMostRecentMessageIsInViewport() onCountChanged: {
d.markAllMessagesReadIfMostRecentMessageIsInViewport()
// after inilial messages are loaded
// load as much messages as the view requires
if (messageStore.initialMessagesLoaded) {
d.loadMoreMessagesIfScrollBelowThreshold()
}
}
onVisibleChanged: d.markAllMessagesReadIfMostRecentMessageIsInViewport() onVisibleChanged: d.markAllMessagesReadIfMostRecentMessageIsInViewport()