Some delay for lazy loading...

This commit is contained in:
Sebastian J. Wolf 2020-09-22 22:46:48 +02:00
parent 2704e29d41
commit 0e1169e7f4
2 changed files with 35 additions and 18 deletions

View file

@ -45,6 +45,8 @@ Item {
} }
function updatePicture() { function updatePicture() {
profileImageLoader.active = false;
replacementThumbnailItem.visible = true;
if (typeof photoData === "object") { if (typeof photoData === "object") {
if (photoData.local.is_downloading_completed) { if (photoData.local.is_downloading_completed) {
profileImageLoader.active = true; profileImageLoader.active = true;
@ -57,7 +59,7 @@ Item {
Timer { Timer {
id: updatePictureTimer id: updatePictureTimer
interval: 100 interval: 500
running: false running: false
repeat: false repeat: false
onTriggered: { onTriggered: {

View file

@ -382,14 +382,12 @@ Page {
} }
onContentYChanged: { onContentYChanged: {
if (!chatPage.loading && !chatView.inCooldown) { if (!chatPage.loading && !chatView.inCooldown && chatView.indexAt(chatView.contentX, chatView.contentY) < 10) {
if (chatView.indexAt(chatView.contentX, chatView.contentY) < 10) {
console.log("[ChatPage] Trying to get older history items..."); console.log("[ChatPage] Trying to get older history items...");
chatView.inCooldown = true; chatView.inCooldown = true;
chatModel.triggerLoadMoreHistory(); chatModel.triggerLoadMoreHistory();
} }
} }
}
onMovementEnded: { onMovementEnded: {
handleScrollPositionChanged(); handleScrollPositionChanged();
@ -449,6 +447,25 @@ Page {
} }
} }
Component.onCompleted: {
delegateComponentLoadingTimer.start();
}
Timer {
id: delegateComponentLoadingTimer
interval: 500
repeat: false
running: false
onTriggered: {
webPagePreviewLoader.active = ( typeof display.content.web_page !== "undefined" );
imagePreviewLoader.active = ( display.content['@type'] === "messagePhoto" );
stickerPreviewLoader.active = ( display.content['@type'] === "messageSticker" );
videoPreviewLoader.active = (( display.content['@type'] === "messageVideo" ) || ( display.content['@type'] === "messageAnimation" ));
audioPreviewLoader.active = (( display.content['@type'] === "messageVoiceNote" ) || ( display.content['@type'] === "messageAudio" ));
documentPreviewLoader.active = ( display.content['@type'] === "messageDocument" );
}
}
RemorseItem { RemorseItem {
id: deleteMessageRemorseItem id: deleteMessageRemorseItem
} }
@ -474,7 +491,7 @@ Page {
Loader { Loader {
id: profileThumbnailLoader id: profileThumbnailLoader
active: ( chatPage.isBasicGroup || chatPage.isSuperGroup ) && !chatPage.isChannel active: (( chatPage.isBasicGroup || chatPage.isSuperGroup ) && !chatPage.isChannel)
asynchronous: true asynchronous: true
width: active ? Theme.itemSizeSmall : 0 width: active ? Theme.itemSizeSmall : 0
height: active ? Theme.itemSizeSmall : 0 height: active ? Theme.itemSizeSmall : 0
@ -513,10 +530,8 @@ Page {
width: messageBackground.width - Theme.horizontalPageMargin width: messageBackground.width - Theme.horizontalPageMargin
anchors.centerIn: messageBackground anchors.centerIn: messageBackground
Component.onCompleted: { Behavior on height {
if (display.reply_to_message_id !== 0) { PropertyAnimation { easing.type: Easing.OutBack; duration: 200 }
tdLibWrapper.getMessage(chatInformation.id, display.reply_to_message_id);
}
} }
Connections { Connections {
@ -579,7 +594,7 @@ Page {
Loader { Loader {
id: webPagePreviewLoader id: webPagePreviewLoader
active: ( typeof display.content.web_page !== "undefined" ) active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: webPagePreviewComponent sourceComponent: webPagePreviewComponent
@ -598,7 +613,7 @@ Page {
Loader { Loader {
id: imagePreviewLoader id: imagePreviewLoader
active: ( display.content['@type'] === "messagePhoto" ) active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: imagePreviewComponent sourceComponent: imagePreviewComponent
@ -616,7 +631,7 @@ Page {
Loader { Loader {
id: stickerPreviewLoader id: stickerPreviewLoader
active: ( display.content['@type'] === "messageSticker" ) active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: stickerPreviewComponent sourceComponent: stickerPreviewComponent
@ -636,7 +651,7 @@ Page {
Loader { Loader {
id: videoPreviewLoader id: videoPreviewLoader
active: (( display.content['@type'] === "messageVideo" ) || ( display.content['@type'] === "messageAnimation" )) active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: videoPreviewComponent sourceComponent: videoPreviewComponent
@ -656,7 +671,7 @@ Page {
Loader { Loader {
id: audioPreviewLoader id: audioPreviewLoader
active: (( display.content['@type'] === "messageVoiceNote" ) || ( display.content['@type'] === "messageAudio" )) active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: audioPreviewComponent sourceComponent: audioPreviewComponent
@ -673,7 +688,7 @@ Page {
Loader { Loader {
id: documentPreviewLoader id: documentPreviewLoader
active: ( display.content['@type'] === "messageDocument" ) active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: documentPreviewComponent sourceComponent: documentPreviewComponent