1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Improve handling unknown attachment format

This commit is contained in:
Zhiyuan Zheng
2021-04-01 01:11:12 +02:00
parent 0644c51a7a
commit 965bab4822
3 changed files with 67 additions and 24 deletions

View File

@ -95,15 +95,46 @@ const TimelineAttachment = React.memo(
/>
)
default:
return (
<AttachmentUnsupported
key={index}
total={status.media_attachments.length}
index={index}
sensitiveShown={sensitiveShown}
attachment={attachment}
/>
)
if (
attachment.preview_url.endsWith('.jpg') ||
attachment.preview_url.endsWith('.jpeg') ||
attachment.preview_url.endsWith('.png') ||
attachment.preview_url.endsWith('.gif') ||
attachment.remote_url?.endsWith('.jpg') ||
attachment.remote_url?.endsWith('.jpeg') ||
attachment.remote_url?.endsWith('.png') ||
attachment.remote_url?.endsWith('.gif')
) {
imageUrls.push({
id: attachment.id,
url: attachment.url,
remote_url: attachment.remote_url,
blurhash: attachment.blurhash,
width: attachment.meta?.original?.width,
height: attachment.meta?.original?.height
})
return (
<AttachmentImage
key={index}
total={status.media_attachments.length}
index={index}
sensitiveShown={sensitiveShown}
// @ts-ignore
image={attachment}
navigateToImagesViewer={navigateToImagesViewer}
/>
)
} else {
return (
<AttachmentUnsupported
key={index}
total={status.media_attachments.length}
index={index}
sensitiveShown={sensitiveShown}
attachment={attachment}
/>
)
}
}
}),
[sensitiveShown]