Fix link preview for received call link previews without title

This commit is contained in:
ayumi-signal 2024-09-23 10:51:16 -07:00 committed by GitHub
parent 3e86bbb1ec
commit a9406a7914
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 18 deletions

View file

@ -1188,6 +1188,16 @@ export class Message extends React.PureComponent<Props, State> {
const isFullSizeImage = shouldUseFullSizeLinkPreviewImage(first); const isFullSizeImage = shouldUseFullSizeLinkPreviewImage(first);
const linkPreviewDate = first.date || null; const linkPreviewDate = first.date || null;
const title =
first.title ||
(first.isCallLink
? i18n('icu:calling__call-link-default-title')
: undefined);
const description =
first.description ||
(first.isCallLink
? i18n('icu:message--call-link-description')
: undefined);
const isClickable = this.areLinksEnabled(); const isClickable = this.areLinksEnabled();
@ -1266,9 +1276,7 @@ export class Message extends React.PureComponent<Props, State> {
isMe={false} isMe={false}
sharedGroupNames={[]} sharedGroupNames={[]}
size={64} size={64}
title={ title={title ?? i18n('icu:calling__call-link-default-title')}
first.title ?? i18n('icu:calling__call-link-default-title')
}
/> />
</div> </div>
)} )}
@ -1280,12 +1288,10 @@ export class Message extends React.PureComponent<Props, State> {
: null : null
)} )}
> >
<div className="module-message__link-preview__title"> <div className="module-message__link-preview__title">{title}</div>
{first.title} {description && (
</div>
{first.description && (
<div className="module-message__link-preview__description"> <div className="module-message__link-preview__description">
{unescape(first.description)} {unescape(description)}
</div> </div>
)} )}
<div className="module-message__link-preview__footer"> <div className="module-message__link-preview__footer">

View file

@ -1820,7 +1820,15 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const incomingPreview = dataMessage.preview || []; const incomingPreview = dataMessage.preview || [];
const preview = incomingPreview const preview = incomingPreview
.map((item: LinkPreviewType) => { .map((item: LinkPreviewType) => {
if (!item.image && !item.title) { if (LinkPreview.isCallLink(item.url)) {
return {
...item,
isCallLink: true,
callLinkRoomId: getRoomIdFromCallLink(item.url),
};
}
if (!item.image || !item.title) {
return null; return null;
} }
// Story link previews don't have to correspond to links in the // Story link previews don't have to correspond to links in the
@ -1835,21 +1843,13 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
return undefined; return undefined;
} }
if (LinkPreview.isCallLink(item.url)) {
return {
...item,
isCallLink: true,
callLinkRoomId: getRoomIdFromCallLink(item.url),
};
}
return item; return item;
}) })
.filter(isNotNil); .filter(isNotNil);
if (preview.length < incomingPreview.length) { if (preview.length < incomingPreview.length) {
log.info( log.info(
`${message.idForLogging()}: Eliminated ${ `${message.idForLogging()}: Eliminated ${
preview.length - incomingPreview.length incomingPreview.length - preview.length
} previews with invalid urls'` } previews with invalid urls'`
); );
} }