mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 13:09:40 +08:00
fix #10953. Dedup of file onStart upload
This commit is contained in:
parent
954c7ecd8e
commit
273fd2ea1b
@ -67,11 +67,18 @@ class Upload extends React.Component<UploadProps, UploadState> {
|
||||
}
|
||||
|
||||
onStart = (file: RcFile) => {
|
||||
let targetItem;
|
||||
let nextFileList = this.state.fileList.concat();
|
||||
targetItem = fileToObject(file);
|
||||
const targetItem = fileToObject(file);
|
||||
targetItem.status = 'uploading';
|
||||
nextFileList.push(targetItem);
|
||||
|
||||
let nextFileList = this.state.fileList.concat();
|
||||
|
||||
const fileIndex = nextFileList.findIndex(({ uid }) => uid === targetItem.uid);
|
||||
if (fileIndex === -1) {
|
||||
nextFileList.push(targetItem);
|
||||
} else {
|
||||
nextFileList[fileIndex] = targetItem;
|
||||
}
|
||||
|
||||
this.onChange({
|
||||
file: targetItem,
|
||||
fileList: nextFileList,
|
||||
|
Loading…
Reference in New Issue
Block a user