mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-12 07:14:37 +00:00
4a30d13bdc
* feat(StatusQ): Adding numberToLocaleStringInCompactForm function to LocaleUtils This function will format the number in a compact form E.g: 1000 -> 1K; 1000000 -> 1M; 1100000 -> 1.1M + adding tests fix(statusQ): Update numberToLocaleStringInCompactForm to return the locale number when greter than 999T fix(StatusQ): extend the test_numberToLocaleStringInCompactForm with new data * feat(LinkPreviews): Update the link preview area in StatusChatInput to use the new model Changes: 1. Create a new component `LinkPreviewMiniCardDelegate.qml` that filters the model data to properly fill the link preview card with the needed data based on the preview type 2. Update storybook pages 3. Small updates to LinkPreviewMiniCard * feat(LinkPreviews): Update the link previews in message history to use the new backend Changes: 1. Create delegate items for LinkPreviewCard and gif link preview to clean the LinksMessageView component and filter the model data based on the preview type 2. Remove UserProfileCard and reuse the LinkPreviewCard to display contacts link previews 3. Update LinkPreviewCard so that it can accommodate status link previews (communities, channels, contacts). The generic properties (title, description, footer) have been dropped and replaced with specialised properties for each preview type. 4. Fix LinkPreviewCard layout to better accommodate different content variants (missing properties, long/short title, missing description, missing icon) 5. Fixing the link preview context menu and click actions fix: Move inline components to separate files Fixing the linux builds using Qt 5.15.2 affected by this bug: https://bugreports.qt.io/browse/QTBUG-89180 * fix: Align LinkPreviewMiniCard implementation with LinkPreviewCard and remove state based model filtering
87 lines
5.4 KiB
QML
87 lines
5.4 KiB
QML
import QtQuick 2.15
|
|
|
|
import utils 1.0
|
|
import shared.controls.chat 1.0
|
|
|
|
LinkPreviewMiniCard {
|
|
id: root
|
|
|
|
/*
|
|
* Model properties
|
|
* The following properties are required to be set by the user of this component
|
|
* unfurled: Whether the link has been unfurled or not
|
|
* empty: Whether the link preview is empty or not
|
|
* url: The url of the link
|
|
* immutable: Whether the link preview can be updated
|
|
* previewType: The type of the preview. See Constants.LinkPreviewType
|
|
* standardPreview: The standard preview data (title, description, linkType, hostname)
|
|
* standardPreviewThumbnail: The standard preview thumbnail data (url, dataUri)
|
|
* statusContactPreview: The status contact preview data (displayName, publicKey, description, icon)
|
|
* statusContactPreviewThumbnail: The status contact preview thumbnail data (url, dataUri)
|
|
* statusCommunityPreview: The status community preview data (communityId, displayName, description, membersCount, color)
|
|
* statusCommunityPreviewIcon: The status community preview icon data (url, dataUri)
|
|
* statusCommunityPreviewBanner: The status community preview banner data (url, dataUri)
|
|
* statusCommunityChannelPreview: The status community channel preview data (channelId, displayName, description, emoji, color)
|
|
* statusCommunityChannelCommunityPreview: The status community channel community preview data (communityId, displayName, description, membersCount, color)
|
|
* statusCommunityChannelCommunityPreviewIcon: The status community channel community preview icon data (url, dataUri)
|
|
* statusCommunityChannelCommunityPreviewBanner: The status community channel community preview banner data (url, dataUri)
|
|
*/
|
|
required property bool unfurled
|
|
required property bool empty
|
|
required property string url
|
|
required property bool immutable
|
|
required property int previewType
|
|
required property var standardPreview
|
|
required property var standardPreviewThumbnail
|
|
required property var statusContactPreview
|
|
required property var statusContactPreviewThumbnail
|
|
required property var statusCommunityPreview
|
|
required property var statusCommunityPreviewIcon
|
|
required property var statusCommunityPreviewBanner
|
|
required property var statusCommunityChannelPreview
|
|
required property var statusCommunityChannelCommunityPreview
|
|
required property var statusCommunityChannelCommunityPreviewIcon
|
|
required property var statusCommunityChannelCommunityPreviewBanner
|
|
|
|
previewState: !root.unfurled ? LinkPreviewMiniCard.State.Loading : root.unfurled && !root.empty ? LinkPreviewMiniCard.State.Loaded : LinkPreviewMiniCard.State.LoadingFailed
|
|
type: root.previewType
|
|
|
|
linkData {
|
|
title: standardPreview ? standardPreview.title : ""
|
|
description: standardPreview ? standardPreview.description : ""
|
|
domain: standardPreview ? standardPreview.hostname : "" //TODO: Use domainName when available
|
|
thumbnail: standardPreviewThumbnail ? (standardPreviewThumbnail.url || standardPreviewThumbnail.dataUri) || "" : ""
|
|
image: "" //TODO: usefavicon when available
|
|
type: standardPreview ? standardPreview.linkType : Constants.StandardLinkPreviewType.Link
|
|
}
|
|
userData {
|
|
name: statusContactPreview ? statusContactPreview.displayName : ""
|
|
publicKey: statusContactPreview ? statusContactPreview.publicKey : ""
|
|
bio: statusContactPreview ? statusContactPreview.description : ""
|
|
image: statusContactPreviewThumbnail ? (statusContactPreviewThumbnail.url || statusContactPreviewThumbnail.dataUri) || "" : ""
|
|
ensVerified: false // not supported yet
|
|
}
|
|
communityData {
|
|
name: statusCommunityPreview ? statusCommunityPreview.displayName : ""
|
|
description: statusCommunityPreview ? statusCommunityPreview.description : ""
|
|
banner: statusCommunityPreviewBanner ? (statusCommunityPreviewBanner.url || statusCommunityPreviewBanner.dataUri) || "" : ""
|
|
image: statusCommunityPreviewIcon ? (statusCommunityPreviewIcon.url || statusCommunityPreviewIcon.dataUri) || "" : ""
|
|
membersCount: statusCommunityPreview ? statusCommunityPreview.membersCount : 0
|
|
color: statusCommunityPreview ? statusCommunityPreview.color : ""
|
|
}
|
|
channelData {
|
|
name: statusCommunityChannelPreview ? statusCommunityChannelPreview.displayName : ""
|
|
description: statusCommunityChannelPreview ? statusCommunityChannelPreview.description : ""
|
|
emoji: statusCommunityChannelPreview ? statusCommunityChannelPreview.emoji : ""
|
|
color: statusCommunityChannelPreview ? statusCommunityChannelPreview.color : ""
|
|
communityData {
|
|
name: statusCommunityChannelCommunityPreview ? statusCommunityChannelCommunityPreview.displayName : ""
|
|
description: statusCommunityChannelCommunityPreview ? statusCommunityChannelCommunityPreview.description : ""
|
|
banner: statusCommunityChannelCommunityPreviewBanner ? (statusCommunityChannelCommunityPreviewBanner.url || statusCommunityChannelCommunityPreviewBanner.dataUri) || "" : ""
|
|
image: statusCommunityChannelCommunityPreviewIcon ? (statusCommunityChannelCommunityPreviewIcon.url || statusCommunityChannelCommunityPreviewIcon.dataUri) || "" : ""
|
|
membersCount: statusCommunityChannelCommunityPreview ? statusCommunityChannelCommunityPreview.membersCount : 0
|
|
color: statusCommunityChannelCommunityPreview ? statusCommunityChannelCommunityPreview.color : ""
|
|
}
|
|
}
|
|
}
|