Lazy-load profile thumbnail

This commit is contained in:
Sebastian J. Wolf 2020-09-21 23:07:30 +02:00
parent c5dade71b0
commit 266dd12570

View file

@ -443,21 +443,33 @@ Page {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Component {
id: profileThumbnailComponent
ProfileThumbnail { ProfileThumbnail {
id: messagePictureThumbnail id: messagePictureThumbnail
photoData: (typeof messageListItem.userInformation.profile_photo !== "undefined") ? messageListItem.userInformation.profile_photo.small : "" photoData: (typeof messageListItem.userInformation.profile_photo !== "undefined") ? messageListItem.userInformation.profile_photo.small : ""
replacementStringHint: userText.text replacementStringHint: userText.text
width: visible ? Theme.itemSizeSmall : 0 width: visible ? Theme.itemSizeSmall : 0
height: visible ? Theme.itemSizeSmall : 0 height: visible ? Theme.itemSizeSmall : 0
visible: ( chatPage.isBasicGroup || chatPage.isSuperGroup ) && !chatPage.isChannel
}
}
Loader {
id: profileThumbnailLoader
active: ( chatPage.isBasicGroup || chatPage.isSuperGroup ) && !chatPage.isChannel
asynchronous: true
width: active ? Theme.itemSizeSmall : 0
height: active ? Theme.itemSizeSmall : 0
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingSmall anchors.bottomMargin: Theme.paddingSmall
visible: ( chatPage.isBasicGroup || chatPage.isSuperGroup ) && !chatPage.isChannel sourceComponent: profileThumbnailComponent
} }
Item { Item {
id: messageTextItem id: messageTextItem
width: parent.width - messagePictureThumbnail.width - Theme.paddingSmall width: parent.width - profileThumbnailLoader.width - Theme.paddingSmall
height: messageBackground.height height: messageBackground.height
Rectangle { Rectangle {