Skip to content

Commit

Permalink
fix: restore await on multiple photo uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
viet nguyen committed Oct 10, 2023
1 parent 3d6245b commit 3ec83e3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/js/hooks/usePhotoUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ export default function usePhotoUploader (): PhotoUploaderReturnType {
}
}

const onDrop = (files: File[], rejections: FileRejection[]): void => {
const onDrop = async (files: File[], rejections: FileRejection[]): Promise<void> => {
if (rejections.length > 0) { console.warn('Rejected files: ', rejections) }

setUploading(true)
ref.current.hasErrors = false
void Promise.all(files.map(async file => {
await Promise.all(files.map(async file => {
if (file.size > 11534336) {
toast.warn('¡Ay, caramba! one of your photos is too cruxy (please reduce the size to 11MB or under)')
return true
Expand All @@ -125,6 +125,7 @@ export default function usePhotoUploader (): PhotoUploaderReturnType {
}

const { getRootProps, getInputProps, open } = useDropzone({
/* eslint-disable-next-line */
onDrop,
multiple: true, // support many
// When I get back from climbing trips, I have a huge pile of photos
Expand Down

0 comments on commit 3ec83e3

Please sign in to comment.