fix: Parallelize loading attachments in document presenter (#2184)
closes #2157
This commit is contained in:
@ -12,13 +12,15 @@ type Options = {
|
|||||||
async function replaceImageAttachments(text: string) {
|
async function replaceImageAttachments(text: string) {
|
||||||
const attachmentIds = parseAttachmentIds(text);
|
const attachmentIds = parseAttachmentIds(text);
|
||||||
|
|
||||||
for (const id of attachmentIds) {
|
await Promise.all(
|
||||||
|
attachmentIds.map(async (id) => {
|
||||||
const attachment = await Attachment.findByPk(id);
|
const attachment = await Attachment.findByPk(id);
|
||||||
if (attachment) {
|
if (attachment) {
|
||||||
const accessUrl = await getSignedImageUrl(attachment.key);
|
const accessUrl = await getSignedImageUrl(attachment.key);
|
||||||
text = text.replace(attachment.redirectUrl, accessUrl);
|
text = text.replace(attachment.redirectUrl, accessUrl);
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user