Make some space for lazy-loaded elements, part 2

This commit is contained in:
Sebastian J. Wolf 2020-10-11 23:11:37 +02:00
parent 67669cf63f
commit d3295bc49a

View file

@ -450,6 +450,11 @@ Page {
property bool isForwarded: typeof display.forward_info !== "undefined" property bool isForwarded: typeof display.forward_info !== "undefined"
property bool containsImage: display.content['@type'] === "messagePhoto" property bool containsImage: display.content['@type'] === "messagePhoto"
property bool containsSticker: display.content['@type'] === "messageSticker" property bool containsSticker: display.content['@type'] === "messageSticker"
property bool containsWebPage: typeof display.content.web_page !== "undefined"
property bool containsVideo: (( display.content['@type'] === "messageVideo" ) || ( display.content['@type'] === "messageAnimation" ));
property bool containsAudio: (( display.content['@type'] === "messageVoiceNote" ) || ( display.content['@type'] === "messageAudio" ));
property bool containsDocument: ( display.content['@type'] === "messageDocument" )
property bool containsLocation: ( display.content['@type'] === "messageLocation" || ( display.content['@type'] === "messageVenue" ))
menu: ContextMenu { menu: ContextMenu {
MenuItem { MenuItem {
@ -500,13 +505,13 @@ Page {
running: false running: false
onTriggered: { onTriggered: {
if (typeof display.content !== "undefined") { if (typeof display.content !== "undefined") {
webPagePreviewLoader.active = ( typeof display.content.web_page !== "undefined" ); webPagePreviewLoader.active = messageListItem.containsWebPage;
imagePreviewLoader.active = messageListItem.containsImage; imagePreviewLoader.active = messageListItem.containsImage;
stickerPreviewLoader.active = messageListItem.containsSticker; stickerPreviewLoader.active = messageListItem.containsSticker;
videoPreviewLoader.active = (( display.content['@type'] === "messageVideo" ) || ( display.content['@type'] === "messageAnimation" )); videoPreviewLoader.active = messageListItem.containsVideo;
audioPreviewLoader.active = (( display.content['@type'] === "messageVoiceNote" ) || ( display.content['@type'] === "messageAudio" )); audioPreviewLoader.active = messageListItem.containsAudio;
documentPreviewLoader.active = ( display.content['@type'] === "messageDocument" ); documentPreviewLoader.active = messageListItem.containsDocument;
locationPreviewLoader.active = ( display.content['@type'] === "messageLocation" || ( display.content['@type'] === "messageVenue" )) locationPreviewLoader.active = messageListItem.containsLocation;
forwardedInformationLoader.active = messageListItem.isForwarded; forwardedInformationLoader.active = messageListItem.isForwarded;
} }
} }
@ -708,22 +713,21 @@ Page {
visible: (text !== "") visible: (text !== "")
} }
Component {
id: webPagePreviewComponent
WebPagePreview {
id: webPagePreview
webPageData: ( typeof display.content.web_page !== "undefined" ) ? display.content.web_page : ""
width: parent.width
visible: typeof display.content.web_page !== "undefined"
}
}
Loader { Loader {
id: webPagePreviewLoader id: webPagePreviewLoader
active: false active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: webPagePreviewComponent height: messageListItem.containsWebPage ? ( item ? item.height : ( (parent.width * 2 / 3) + (6 * Theme.fontSizeExtraSmall) + ( 7 * Theme.paddingSmall) ) ) : 0
sourceComponent: Component {
id: webPagePreviewComponent
WebPagePreview {
id: webPagePreview
webPageData: messageListItem.containsWebPage ? display.content.web_page : ""
width: parent.width
}
}
} }
Loader { Loader {
@ -761,52 +765,39 @@ Page {
} }
} }
Component {
id: videoPreviewComponent
VideoPreview {
id: messageVideoPreview
videoData: ( display.content['@type'] === "messageVideo" ) ? display.content.video : ( ( display.content['@type'] === "messageAnimation" ) ? display.content.animation : "")
width: parent.width
height: ( display.content['@type'] === "messageVideo" ) ? Functions.getVideoHeight(width, display.content.video) : Functions.getVideoHeight(width, display.content.animation)
visible: ( display.content['@type'] === "messageVideo" || display.content['@type'] === "messageAnimation" )
onScreen: chatPage.status === PageStatus.Active
}
}
Loader { Loader {
id: videoPreviewLoader id: videoPreviewLoader
active: false active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: videoPreviewComponent height: messageListItem.containsVideo ? Functions.getVideoHeight(width, ( display.content['@type'] === "messageVideo" ) ? display.content.video : display.content.animation) : 0
} sourceComponent: Component {
id: videoPreviewComponent
Component { VideoPreview {
id: audioPreviewComponent id: messageVideoPreview
AudioPreview { videoData: ( display.content['@type'] === "messageVideo" ) ? display.content.video : ( ( display.content['@type'] === "messageAnimation" ) ? display.content.animation : "")
id: messageAudioPreview
audioData: ( display.content['@type'] === "messageVoiceNote" ) ? display.content.voice_note : ( ( display.content['@type'] === "messageAudio" ) ? display.content.audio : "")
width: parent.width width: parent.width
height: parent.width / 2 height: Functions.getVideoHeight(width, ( display.content['@type'] === "messageVideo" ) ? display.content.video : display.content.animation)
visible: ( display.content['@type'] === "messageVoiceNote" || display.content['@type'] === "messageAudio" )
onScreen: chatPage.status === PageStatus.Active onScreen: chatPage.status === PageStatus.Active
} }
} }
}
Loader { Loader {
id: audioPreviewLoader id: audioPreviewLoader
active: false active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: audioPreviewComponent height: messageListItem.containsAudio ? (parent.width / 2) : 0
sourceComponent: Component {
id: audioPreviewComponent
AudioPreview {
id: messageAudioPreview
audioData: ( display.content['@type'] === "messageVoiceNote" ) ? display.content.voice_note : ( ( display.content['@type'] === "messageAudio" ) ? display.content.audio : "")
width: parent.width
height: parent.width / 2
onScreen: chatPage.status === PageStatus.Active
} }
Component {
id: documentPreviewComponent
DocumentPreview {
id: messageDocumentPreview
documentData: ( display.content['@type'] === "messageDocument" ) ? display.content.document : ""
visible: display.content['@type'] === "messageDocument"
} }
} }
@ -815,17 +806,13 @@ Page {
active: false active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: documentPreviewComponent height: messageListItem.containsDocument ? (item ? item.height : Theme.itemSizeSmall) : 0
sourceComponent: Component {
id: documentPreviewComponent
DocumentPreview {
id: messageDocumentPreview
documentData: messageListItem.containsDocument ? display.content.document : ""
} }
Component {
id: locationPreviewComponent
LocationPreview {
id: messageLocationPreview
width: parent.width
height: parent.width * 2 / 3
chatId: display.id
locationData: ( display.content['@type'] === "messageLocation" ) ? display.content.location : ( ( display.content['@type'] === "messageVenue" ) ? display.content.venue.location : "" )
visible: ( display.content['@type'] === "messageLocation" || display.content['@type'] === "messageVenue" )
} }
} }
@ -834,8 +821,19 @@ Page {
active: false active: false
asynchronous: true asynchronous: true
width: parent.width width: parent.width
sourceComponent: locationPreviewComponent height: messageListItem.containsLocation ? (item ? item.height : (parent.width * 2 / 3)) : 0
sourceComponent: Component {
id: locationPreviewComponent
LocationPreview {
id: messageLocationPreview
width: parent.width
height: parent.width * 2 / 3
chatId: display.id
locationData: ( display.content['@type'] === "messageLocation" ) ? display.content.location : ( ( display.content['@type'] === "messageVenue" ) ? display.content.venue.location : "" )
} }
}
}
Timer { Timer {
id: messageDateUpdater id: messageDateUpdater
interval: 60000 interval: 60000