fix(create): uploading file adds to the existing file list, dedupe file list
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 33s

Closes #184
This commit is contained in:
enes 2024-09-17 17:56:53 +02:00
parent c52fecdf4e
commit 6d78d9ed64

View File

@ -301,7 +301,15 @@ export const CreatePage = () => {
const handleSelectFiles = (event: React.ChangeEvent<HTMLInputElement>) => { const handleSelectFiles = (event: React.ChangeEvent<HTMLInputElement>) => {
if (event.target.files) { if (event.target.files) {
setSelectedFiles(Array.from(event.target.files)) // Get the uploaded files
const files = Array.from(event.target.files)
// Remove duplicates based on the file.name
setSelectedFiles((p) =>
[...p, ...files].filter(
(file, i, array) => i === array.findIndex((t) => t.name === file.name)
)
)
} }
} }