diff --git a/.changeset/fix-crash-with-some-embeds.md b/.changeset/fix-crash-with-some-embeds.md new file mode 100644 index 000000000..8b2df3a4c --- /dev/null +++ b/.changeset/fix-crash-with-some-embeds.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix crash with some embed links. diff --git a/src/app/components/message/content/ImageContent.tsx b/src/app/components/message/content/ImageContent.tsx index fd51775d8..57e7acd2e 100644 --- a/src/app/components/message/content/ImageContent.tsx +++ b/src/app/components/message/content/ImageContent.tsx @@ -83,7 +83,7 @@ type RenderImageProps = { tabIndex: number; }; export type ImageContentProps = { - body: string; + body?: string; mimeType?: string; url: string; info?: IImageInfo; @@ -141,9 +141,9 @@ export const ImageContent = as<'div', ImageContentProps>( info?.mimetype === 'image/gif' || info?.mimetype === 'image/apng' || info?.mimetype === 'image/webp' || - body.toLowerCase().endsWith('.gif') || - body.toLowerCase().endsWith('.apng') || - body.toLowerCase().endsWith('.webp') || + (body ?? '').toLowerCase().endsWith('.gif') || + (body ?? '').toLowerCase().endsWith('.apng') || + (body ?? '').toLowerCase().endsWith('.webp') || url.toLowerCase().endsWith('.gif') || url.toLowerCase().endsWith('.apng') || url.toLowerCase().endsWith('.webp'); @@ -269,7 +269,7 @@ export const ImageContent = as<'div', ImageContentProps>( > {renderViewer({ src: viewerFullSrc ?? srcState.data, - alt: body, + alt: body ?? '', requestClose: () => setViewer(false), info: info, })} @@ -315,8 +315,8 @@ export const ImageContent = as<'div', ImageContentProps>( style={{ width: '100%' }} > {renderImage({ - alt: body, - title: body, + alt: body ?? '', + title: body ?? '', src: srcState.data, onLoad: handleLoad, onError: handleError, @@ -437,7 +437,7 @@ export const ImageContent = as<'div', ImageContentProps>( gifs: [ ...favoritedContent.gifs, { - title: body, + title: body ?? '', url: url, width: imageW, height: imageH,