fix #10953. Dedup of file onStart upload

This commit is contained in:
zombiej 2018-09-19 22:37:35 +08:00
parent 954c7ecd8e
commit 273fd2ea1b

View File

@ -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,