diff --git a/web/src/components/delimiter.tsx b/web/src/components/delimiter.tsx index a79440874..8a592dedc 100644 --- a/web/src/components/delimiter.tsx +++ b/web/src/components/delimiter.tsx @@ -30,7 +30,7 @@ const Delimiter = () => { diff --git a/web/src/components/file-upload-modal/index.tsx b/web/src/components/file-upload-modal/index.tsx index 8dba74846..cc6b545aa 100644 --- a/web/src/components/file-upload-modal/index.tsx +++ b/web/src/components/file-upload-modal/index.tsx @@ -68,7 +68,10 @@ const FileUpload = ({ ); }; -interface IFileUploadModalProps extends IModalProps { +interface IFileUploadModalProps + extends IModalProps< + { parseOnCreation: boolean; directoryFileList: UploadFile[] } | UploadFile[] + > { uploadFileList?: UploadFile[]; setUploadFileList?: Dispatch>; uploadProgress?: number; @@ -108,7 +111,9 @@ const FileUploadModal = ({ } const ret = await onFileUploadOk?.( - fileList ? parseOnCreation : [...currentFileList, ...directoryFileList], + fileList + ? { parseOnCreation, directoryFileList } + : [...currentFileList, ...directoryFileList], ); return ret; }; diff --git a/web/src/pages/add-knowledge/components/knowledge-file/hooks.ts b/web/src/pages/add-knowledge/components/knowledge-file/hooks.ts index a7697dd7a..1105e1c78 100644 --- a/web/src/pages/add-knowledge/components/knowledge-file/hooks.ts +++ b/web/src/pages/add-knowledge/components/knowledge-file/hooks.ts @@ -148,7 +148,13 @@ export const useHandleUploadDocument = () => { const { runDocumentByIds, loading: _ } = useRunNextDocument(); const onDocumentUploadOk = useCallback( - async (parseOnCreation: boolean): Promise => { + async ({ + parseOnCreation, + directoryFileList, + }: { + directoryFileList: UploadFile[]; + parseOnCreation: boolean; + }): Promise => { const processFileGroup = async (filesPart: UploadFile[]) => { // set status to uploading on files setFileList( @@ -192,9 +198,18 @@ export const useHandleUploadDocument = () => { totalSuccess: succesfulFilenames.length, }; }; - const totalFiles = fileList.length; + if (directoryFileList.length > 0) { + const ret = await uploadDocument(directoryFileList); + if (ret?.code === 0) { + hideDocumentUploadModal(); + } + if (totalFiles === 0) { + return 0; + } + } + if (totalFiles === 0) { console.log('No files to upload'); hideDocumentUploadModal();