Fix getting multiple files from drag event

This commit is contained in:
Eduard Kuzmenko 2020-12-15 17:34:37 +02:00
parent 5e13c8bd91
commit b630c74b21

View File

@ -640,13 +640,16 @@ export async function getFilesFromEvent(e: ClipboardEvent | DragEvent, onlyTypes
// @ts-ignore // @ts-ignore
const items = (e.dataTransfer || e.clipboardData || e.originalEvent.clipboardData).items; const items = (e.dataTransfer || e.clipboardData || e.originalEvent.clipboardData).items;
const promises: Promise<any>[] = [];
for(let i = 0; i < items.length; ++i) { for(let i = 0; i < items.length; ++i) {
const item: DataTransferItem = items[i]; const item: DataTransferItem = items[i];
if(item.kind === 'file') { if(item.kind === 'file') {
const entry = onlyTypes ? item : item.webkitGetAsEntry() || item.getAsFile(); const entry = (onlyTypes ? item : item.webkitGetAsEntry()) || item.getAsFile();
await scanFiles(entry); promises.push(scanFiles(entry));
} }
} }
await Promise.all(promises);
} }
/* if(!onlyTypes) { /* if(!onlyTypes) {