Skip to content
Permalink
Browse files

fix #10953. Dedup of file onStart upload

  • Loading branch information
zombieJ committed Sep 19, 2018
1 parent 954c7ec commit 273fd2ea1bca395d61509cc98c3ebbf1c620bf43
Showing with 11 additions and 4 deletions.
  1. +11 −4 components/upload/Upload.tsx
@@ -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();

This comment has been minimized.

Copy link
@afc163

afc163 Sep 19, 2018

Member

好像不需要用 let


const fileIndex = nextFileList.findIndex(({ uid }) => uid === targetItem.uid);
if (fileIndex === -1) {
nextFileList.push(targetItem);
} else {
nextFileList[fileIndex] = targetItem;
}

this.onChange({
file: targetItem,
fileList: nextFileList,

0 comments on commit 273fd2e

Please sign in to comment.