From 91ea4577f1549be74b8f036293ca3fa0a56d7bd5 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 18 May 2024 14:58:48 -0500 Subject: [PATCH] Filter out attachments with no url --- src/views/mastodon/attachments.ts | 4 +++- src/views/mastodon/statuses.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/views/mastodon/attachments.ts b/src/views/mastodon/attachments.ts index 1dbcda9..9f8e5c3 100644 --- a/src/views/mastodon/attachments.ts +++ b/src/views/mastodon/attachments.ts @@ -12,8 +12,10 @@ function renderAttachment(tags: string[][]) { const uuid = tags.find(([name]) => name === 'uuid')?.[1]; const blurhash = tags.find(([name]) => name === 'blurhash')?.[1]; + if (!url) return; + return { - id: uuid, + id: uuid ?? url, type: getAttachmentType(m ?? ''), url, preview_url: url, diff --git a/src/views/mastodon/statuses.ts b/src/views/mastodon/statuses.ts index 889c23d..16ba482 100644 --- a/src/views/mastodon/statuses.ts +++ b/src/views/mastodon/statuses.ts @@ -106,7 +106,7 @@ async function renderStatus(event: DittoEvent, opts: RenderStatusOpts): Promise< pinned: Boolean(pinEvent), reblog: null, application: null, - media_attachments: media.map(renderAttachment), + media_attachments: media.map(renderAttachment).filter(Boolean), mentions, tags: [], emojis: renderEmojis(event),