Insert media URL into text

This commit is contained in:
Alex Gleason
2024-05-18 15:29:12 -05:00
parent 91ea4577f1
commit b1b341d3b8
2 changed files with 21 additions and 16 deletions

View File

@@ -51,11 +51,17 @@ async function deleteUnattachedMediaByUrl(url: string) {
}
/** Get unattached media by IDs. */
async function getUnattachedMediaByIds(kysely: Kysely<DittoTables>, ids: string[]) {
async function getUnattachedMediaByIds(kysely: Kysely<DittoTables>, ids: string[]): Promise<UnattachedMedia[]> {
if (!ids.length) return [];
return await selectUnattachedMediaQuery(kysely)
const results = await selectUnattachedMediaQuery(kysely)
.where('id', 'in', ids)
.execute();
return results.map((row) => ({
...row,
data: JSON.parse(row.data),
}));
}
/** Delete rows as an event with media is being created. */