Fix async picker race
This commit is contained in:
@@ -25,7 +25,13 @@ export async function addFiles(state, cfg, files, elements) {
|
||||
}
|
||||
|
||||
export function onFilesChange(state, cfg, elements) {
|
||||
return () => {
|
||||
if (!state.busy) addFiles(state, cfg, elements.fileInputEl.files, elements);
|
||||
return async () => {
|
||||
if (state.busy) return;
|
||||
state.busy = true;
|
||||
try {
|
||||
await addFiles(state, cfg, elements.fileInputEl.files, elements);
|
||||
} finally {
|
||||
state.busy = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user