The event handlers from the fileDropZone don't work amazingly. When uploading a few small files, the event handler (On file uploaded) works fine. When uploading 6 or 7 bigger files, the event handler files before the state of the fileDropZone has updated its value. I have this script which is currently on the on file upload event (The aim is to upload a list of uploaded files to a database table on the retoolDB)
console.log("Uploaded event fired: " + fileDropzone1.value.length + " files processed");
await fileDropzone1.value.forEach(async f => {
await files_AddNew.trigger({
additionalScope: {
file_id: f.fileId,
friendly_name: f.name,
file_size: f.sizeBytes
}
});
This works fine if only a few small files are uploaded. I even tried adding a do loop to try and not fire the event until the state had updated the value, but now it doesn't seem to do anything at all:
do {
if(fileDropzone1.value.length > 0) {
console.log("Uploaded event fired: " + fileDropzone1.value.length + " files processed");
await fileDropzone1.value.forEach(async f => {
await files_AddNew.trigger({
additionalScope: {
file_id: f.fileId,
friendly_name: f.name,
file_size: f.sizeBytes
}
});
await window.resetQuery(files_GetFiles);
console.log("Uploaded event finished");
});
break;
}
}
while (fileDropzone1.value.length == 0);
Any ideas? It would be amazing if the retool storage queries could accept additionalData much like the other queries, then I could handle the uploading of the documents myself
Edit - i've added a debounce time which now works, but not ideal as if even bigger files are uploaded, it may take longer. Ideally, the event would only fire once the state of the dropzone has updated, but it seems to be doing this beforehand or asynchronously.