Skip to content

Commit

Permalink
fix(uploader): pre-upload pmage preview bug (#2416)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-huxiyang authored Jul 5, 2024
1 parent 958d83d commit c8e5570
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
6 changes: 2 additions & 4 deletions src/packages/uploader/uploader.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ const InternalUploader: ForwardRefRenderFunction<
setUploadQueue(uploadQueue)
} else {
setUploadQueue([])
fileList.splice(0, fileList.length)
setFileList([...fileList])
setFileList([])
}
}

Expand Down Expand Up @@ -425,8 +424,7 @@ const InternalUploader: ForwardRefRenderFunction<
if (preview) {
fileItem.url = fileType === 'video' ? file.thumbTempFilePath : filepath
}
fileList.push(fileItem)
setFileList(fileList)
setFileList([...fileList, fileItem])
executeUpload(fileItem, index)
})
}
Expand Down
9 changes: 3 additions & 6 deletions src/packages/uploader/uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ const InternalUploader: ForwardRefRenderFunction<
setUploadQueue(uploadQueue)
} else {
setUploadQueue([])
fileList.splice(0, fileList.length)
setFileList([...fileList])
setFileList([])
}
}

Expand Down Expand Up @@ -301,13 +300,11 @@ const InternalUploader: ForwardRefRenderFunction<
const reader = new FileReader()
reader.onload = (event: ProgressEvent<FileReader>) => {
fileItem.url = (event.target as FileReader).result as string
fileList.push(fileItem)
setFileList([...fileList])
setFileList([...fileList, fileItem])
}
reader.readAsDataURL(file)
} else {
fileList.push(fileItem)
setFileList([...fileList])
setFileList([...fileList, fileItem])
}
})
}
Expand Down

0 comments on commit c8e5570

Please sign in to comment.