mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 14:14:17 +08:00
perf: parallelize file uploads and add consistent drag validation
Use Promise.all for concurrent file uploads instead of sequential processing, improving upload performance for multiple files. Also add isFileDrag check to handleFolderDragOver for consistency with other drag handlers.
This commit is contained in:
parent
c979b59e1e
commit
fe0ea13f70
@ -71,14 +71,16 @@ export function useFileDrop() {
|
||||
return
|
||||
|
||||
try {
|
||||
for (const file of files) {
|
||||
await createFile.mutateAsync({
|
||||
appId,
|
||||
name: file.name,
|
||||
file,
|
||||
parentId: targetFolderId,
|
||||
})
|
||||
}
|
||||
await Promise.all(
|
||||
files.map(file =>
|
||||
createFile.mutateAsync({
|
||||
appId,
|
||||
name: file.name,
|
||||
file,
|
||||
parentId: targetFolderId,
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
Toast.notify({
|
||||
type: 'success',
|
||||
|
||||
@ -62,7 +62,7 @@ export function useFolderFileDrop(node: NodeApi<TreeNodeData>): UseFolderFileDro
|
||||
}, [isFolder, scheduleAutoExpand])
|
||||
|
||||
const handleFolderDragOver = useCallback((e: React.DragEvent) => {
|
||||
if (!isFolder)
|
||||
if (!isFolder || !isFileDrag(e))
|
||||
return
|
||||
handleDragOver(e, { folderId: node.data.id, isFolder: true })
|
||||
}, [handleDragOver, isFolder, node.data.id])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user