pingdotgg / uploadthing

File uploads for modern web devs
https://uploadthing.com
MIT License
4.13k stars 305 forks source link

fix: `onUploadProgress` events out of order #860

Closed juliusmarminge closed 3 months ago

juliusmarminge commented 3 months ago

Closes #859

prefilling the map fixes the average calculation as some items might not be uplaoding from the start

CleanShot 2024-06-16 at 11 24 08@2x

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-uploadthing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 16, 2024 9:36am
changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: 5cee5ed2e31719c88b2485b13d3e85786c323c51

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages | Name | Type | | ------------------- | ----- | | @uploadthing/react | Patch | | @uploadthing/solid | Patch | | @uploadthing/svelte | Patch | | @uploadthing/vue | Patch | | @uploadthing/expo | Patch | | @uploadthing/nuxt | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

juliusmarminge commented 3 months ago

This calculation does seem a bit sus though and not very accurate calculating the average progress like this: https://github.com/pingdotgg/uploadthing/pull/860/files#diff-d60d183d4e527ceee4ad5a7201e868c9a872add70f50bdb4755c50e63b8fa74cR78-R79

If you upload 1 large file and 1 small file the small will upload immediately and bump the progress to 50% even though the large file might not be close to done yet.

marclelamy commented 3 months ago

Instead of calculating the total progress, would it be possible to return an array of all files along with their progress? Or maybe generate an event for each file's percent completion? It would be awesome to have a progress bar next to each file (from image below) with the current progress displayed. I really like the logs you have in your console!

CleanShot 2024-06-13 at 20 36 16

juliusmarminge commented 3 months ago

It would be awesome to have a progress bar next to each file (from image below) with the current progress displayed. I really like the logs you have in your console!

A change like that would require changing the signature which would be a breaking change. Even adding a second argument with the map would technically be a breaking change if you're really nitpicky.

We are working on v7, so file a feature request for that and I'm sure we can consider it for then next major!