diff --git a/src/components/frame/XImgWorker.ts b/src/components/frame/XImgWorker.ts index c1c0e714..ab721ccc 100644 --- a/src/components/frame/XImgWorker.ts +++ b/src/components/frame/XImgWorker.ts @@ -214,9 +214,8 @@ async function fetchImage(url: string): Promise { const cache = await imageCache?.match(url); if (cache) return await cache.blob(); - // Get file id from URL + // Parse URL const urlObj = new URL(url, self.location.origin); - const fileid = Number(urlObj.pathname.split('/').pop()); // Just fetch if not a preview const regex = /^.*\/apps\/memories\/api\/image\/preview\/.*/; @@ -227,6 +226,9 @@ async function fetchImage(url: string): Promise { return await res.blob(); } + // Get file id from URL + const fileid = Number(urlObj.pathname.split('/').pop()); + return await new Promise((resolve, reject) => { if (pendingUrls.has(url)) { // Already in queue, just add callback