Skip to content

Commit

Permalink
fix: duplicate image upload on upload file list component
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoninoBonanno authored and astagi committed Jul 14, 2023
1 parent 8b40b0d commit 41a12f2
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,21 @@ export class ItUploadFileListComponent extends ItAbstractComponent implements On
* @param event
*/
onLoadFiles(event: Event): void {
const files = (event.target as HTMLInputElement)?.files;
const input = event.target as HTMLInputElement;
const files = input?.files;
if (!files?.length) {
return;
}
this.uploadFiles.emit(files);

const newFiles = Array.from(files).filter(file => !this.fileList.some(item => {
return item.file.name === file.name && item.file.size === file.size && item.file.type === file.type
}));

const fileList = new DataTransfer();
newFiles.forEach(file => fileList.items.add(file));

this.uploadFiles.emit(fileList.files);
input.value = '';
}

/**
Expand Down

0 comments on commit 41a12f2

Please sign in to comment.