Remove unattached_media table, replace with LRUCache, fix media upload order problem

This commit is contained in:
Alex Gleason
2024-09-07 10:24:56 -05:00
parent 85000cd00e
commit 8efd6fbb20
10 changed files with 100 additions and 139 deletions

View File

@@ -3,9 +3,9 @@ import { getUrlMediaType } from '@/utils/media.ts';
/** Render Mastodon media attachment. */
function renderAttachment(
media: { id?: string; data: string[][] },
media: { id?: string; tags: string[][] },
): (MastodonAttachment & { cid?: string }) | undefined {
const { id, data: tags } = media;
const { id, tags } = media;
const url = tags.find(([name]) => name === 'url')?.[1];

View File

@@ -125,9 +125,9 @@ async function renderStatus(event: DittoEvent, opts: RenderStatusOpts): Promise<
pinned: Boolean(pinEvent),
reblog: null,
application: null,
media_attachments: media.map((m) => renderAttachment({ data: m })).filter((m): m is MastodonAttachment =>
Boolean(m)
),
media_attachments: media
.map((m) => renderAttachment({ tags: m }))
.filter((m): m is MastodonAttachment => Boolean(m)),
mentions,
tags: [],
emojis: renderEmojis(event),