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-12 14:01:43 +02:00
parent 5e6b8303b1
commit cf7f3d3af8
3 changed files with 14 additions and 4 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

@ -1 +1 @@
Subproject commit 427cc9848f43e5ed88be897341709ebed79bb354
Subproject commit 80e3a7377b6f42f43f46d706a47cc2dea827682b