Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| onChange(newValue); | ||
| files: acceptedFiles, | ||
| onComplete: (newUploads) => { | ||
| onChange(arrayUnion(newUploads)); |
There was a problem hiding this comment.
We can’t use arrayUnion here because this goes in the local state, which doesn’t handle this Firestore-specific value. If a row is local (e.g. created with random ID), when the files are uploaded, the cell value appears blank.
Screen.Recording.2022-11-15.at.07.22.58.movScreen.Recording.2022-11-15.at.08.21.30.mov |
| return new Promise((resolve) => | ||
| files.forEach((file) => { |
There was a problem hiding this comment.
I’m confused with how this is working. You create one promise when multiple files are uploaded, and it seems to resolve the promise when only one of those files are uploaded or fails to upload. Am I missing something here?
There was a problem hiding this comment.
It pushes a value into uploads or failures when onComplete/onError independently for each upload process, this promise only resolves once the total length of those matches with the input files length.
There was a problem hiding this comment.
Oh I missed the isCompleted() calls. An alternative solution is to create an array of promises for each file, which resolve when the file is added to uploads or failures. Then, create a new promise using Promise.all( <array of promises> ) and wait for that to resolve. Your solution works fine though.
No description provided.