Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(uploader): pre-upload pmage preview bug #2416

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/packages/uploader/uploader.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ const InternalUploader: ForwardRefRenderFunction<
setUploadQueue(uploadQueue)
} else {
setUploadQueue([])
fileList.splice(0, fileList.length)
setFileList([...fileList])
setFileList([])
Alex-huxiyang marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -425,8 +424,7 @@ const InternalUploader: ForwardRefRenderFunction<
if (preview) {
fileItem.url = fileType === 'video' ? file.thumbTempFilePath : filepath
}
fileList.push(fileItem)
setFileList(fileList)
setFileList([...fileList, fileItem])
Alex-huxiyang marked this conversation as resolved.
Show resolved Hide resolved
executeUpload(fileItem, index)
})
}
Expand Down
9 changes: 3 additions & 6 deletions src/packages/uploader/uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@
setUploadQueue(uploadQueue)
} else {
setUploadQueue([])
fileList.splice(0, fileList.length)
setFileList([...fileList])
setFileList([])

Check warning on line 176 in src/packages/uploader/uploader.tsx

View check run for this annotation

Codecov / codecov/patch

src/packages/uploader/uploader.tsx#L176

Added line #L176 was not covered by tests
Alex-huxiyang marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -301,13 +300,11 @@
const reader = new FileReader()
reader.onload = (event: ProgressEvent<FileReader>) => {
fileItem.url = (event.target as FileReader).result as string
fileList.push(fileItem)
setFileList([...fileList])
setFileList([...fileList, fileItem])

Check warning on line 303 in src/packages/uploader/uploader.tsx

View check run for this annotation

Codecov / codecov/patch

src/packages/uploader/uploader.tsx#L303

Added line #L303 was not covered by tests
Alex-huxiyang marked this conversation as resolved.
Show resolved Hide resolved
}
reader.readAsDataURL(file)
} else {
fileList.push(fileItem)
setFileList([...fileList])
setFileList([...fileList, fileItem])

Check warning on line 307 in src/packages/uploader/uploader.tsx

View check run for this annotation

Codecov / codecov/patch

src/packages/uploader/uploader.tsx#L307

Added line #L307 was not covered by tests
}
})
}
Expand Down
Loading