Chat loading : sync load on "visible" (estimate) items. Load more entries if visible area can contain more than current entries on first display.

This commit is contained in:
Julien Wadel 2023-07-26 16:52:03 +02:00
parent 236e67fb6a
commit 245f2eead7
2 changed files with 13 additions and 3 deletions

View file

@ -36,7 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Display video thumbnails.
- Crop thumbnail and pictures if distored.
- Enable registration from accounts list.
- Update SDK to 5.2.88
- Update SDK to 5.2.89
### Removed
- Picture zoom on mouse over.

View file

@ -67,7 +67,8 @@ Rectangle {
// Load optimizations
property int remainingLoadersCount: 0
property int syncLoaderBatch: 20 // batch of simultaneous loaders on synchronous mode
property int visibleItemsEstimation: chat.height / (2 * textMetrics.height) // Title + body
property int syncLoaderBatch: visibleItemsEstimation // batch of simultaneous loaders on synchronous mode
//------------------------------------
signal refreshContents()
@ -93,6 +94,11 @@ Rectangle {
running: false
onTriggered: chat.refreshContents()
}
TextMetrics{
id: textMetrics
font: SettingsModel.textMessageFont
text: "X"
}
Layout.fillHeight: true
Layout.fillWidth: true
@ -110,6 +116,9 @@ Rectangle {
Component.onCompleted: {
Logic.initView()
refreshContentsTimer.start()
console.debug("Chat loading with "+chat.visibleItemsEstimation+" visible items. "+chat.count)
if(chat.visibleItemsEstimation >= chat.count)
Qt.callLater(container.proxyModel.loadMoreEntriesAsync)
}
onMovementStarted: {Logic.handleMovementStarted(); chat.isMoving = true}
onMovementEnded: {Logic.handleMovementEnded(); chat.isMoving = false}
@ -235,7 +244,8 @@ Rectangle {
Layout.fillWidth: true
source: Logic.getComponentFromEntry(entry.chatEntry)
z:1
asynchronous: index != chat.count - 1
asynchronous: index < chat.count - 1 - chat.visibleItemsEstimation
property int loaderIndex: 0
function updateSync(){
if( asynchronous && loaderIndex > 0 && chat.remainingLoadersCount - loaderIndex - chat.syncLoaderBatch <= 0 ) asynchronous = false// Sync load the end