From 0df6f3e56e80f31c730d8b6d0372c075cd156978 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 6 Jun 2024 00:44:41 +0200 Subject: [PATCH] simplify idb import --- website/src/repl/idbutils.mjs | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/website/src/repl/idbutils.mjs b/website/src/repl/idbutils.mjs index 70ccd8f8f..1648bf87a 100644 --- a/website/src/repl/idbutils.mjs +++ b/website/src/repl/idbutils.mjs @@ -142,29 +142,22 @@ function openDB(config, onOpened) { async function processFilesForIDB(files) { return Promise.all( Array.from(files) - .map((s) => { - const title = s.name; + .map((file) => { + const title = file.name; if (!isAudioFile(title)) { return; } - //create obscured url to file system that can be fetched - const sUrl = URL.createObjectURL(s); - //fetch the sound and turn it into a buffer array - return fetch(sUrl).then((res) => { - return res.blob().then((blob) => { - const path = s.webkitRelativePath; - let id = path?.length ? path : title; - if (id == null || title == null || blob == null) { - return; - } - return { - title, - blob, - id, - }; - }); - }); + const path = file.webkitRelativePath; + let id = path?.length ? path : title; + if (id == null || title == null || file == null) { + return; + } + return { + title, + blob: file, + id, + }; }) .filter(Boolean), ).catch((error) => {