From 9da1152311cbce58d1912b680d6b61fbc0ae04f3 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:32:14 -0500 Subject: [PATCH] StagedLinkPreview: Add special handling for call links Co-authored-by: Scott Nonnenberg --- stylesheets/components/StagedLinkPreview.scss | 4 + .../conversation/StagedLinkPreview.tsx | 118 ++++++++++++------ 2 files changed, 86 insertions(+), 36 deletions(-) diff --git a/stylesheets/components/StagedLinkPreview.scss b/stylesheets/components/StagedLinkPreview.scss index 17f030cc04f6..f5d7ed252556 100644 --- a/stylesheets/components/StagedLinkPreview.scss +++ b/stylesheets/components/StagedLinkPreview.scss @@ -48,6 +48,10 @@ .module-staged-link-preview__icon-container { margin-inline-end: 8px; } +.module-staged-link-preview__icon-container-call-link { + margin-inline-end: 8px; + margin: 4px; +} .module-staged-link-preview__content { display: flex; flex-direction: column; diff --git a/ts/components/conversation/StagedLinkPreview.tsx b/ts/components/conversation/StagedLinkPreview.tsx index 8a37ade95b18..aa7bbb01faa1 100644 --- a/ts/components/conversation/StagedLinkPreview.tsx +++ b/ts/components/conversation/StagedLinkPreview.tsx @@ -12,6 +12,10 @@ import type { LinkPreviewType } from '../../types/message/LinkPreviews'; import type { LocalizerType } from '../../types/Util'; import { getClassNamesFor } from '../../util/getClassNamesFor'; import { isImageAttachment } from '../../types/Attachment'; +import { isCallLink } from '../../types/LinkPreview'; +import { Avatar } from '../Avatar'; +import { getColorForCallLink } from '../../util/getColorForCallLink'; +import { getKeyFromCallLink } from '../../util/callLinks'; export type Props = LinkPreviewType & { i18n: LocalizerType; @@ -20,18 +24,9 @@ export type Props = LinkPreviewType & { onClose?: () => void; }; -export function StagedLinkPreview({ - date, - description, - domain, - i18n, - image, - imageSize, - moduleClassName, - onClose, - title, -}: Props): JSX.Element { - const isImage = isImageAttachment(image); +export function StagedLinkPreview(props: Props): JSX.Element { + const { date, description, domain, i18n, moduleClassName, onClose, title } = + props; const isLoaded = Boolean(domain); const getClassName = getClassNamesFor( @@ -79,30 +74,7 @@ export function StagedLinkPreview({ !isLoaded ? getClassName('--is-loading') : null )} > - {!isLoaded ? ( -
- {i18n('icu:loadingPreview')} -
- ) : null} - {isLoaded && image && isImage && domain ? ( -
- {i18n('icu:stagedPreviewThumbnail', -
- ) : null} - {isLoaded && !image &&
} + {maybeContent} {onClose && (