mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? fix: Change document status with @tanstack/react-query #13306 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe):
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
import { useShowDeleteConfirm } from '@/hooks/common-hooks';
|
||||
import { ResponsePostType } from '@/interfaces/database/base';
|
||||
import { IKnowledge, ITestingResult } from '@/interfaces/database/knowledge';
|
||||
import i18n from '@/locales/config';
|
||||
@ -11,8 +10,7 @@ import {
|
||||
useQueryClient,
|
||||
} from '@tanstack/react-query';
|
||||
import { message } from 'antd';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
||||
import { useSearchParams } from 'umi';
|
||||
import { useSetPaginationParams } from './route-hook';
|
||||
|
||||
export const useKnowledgeBaseId = (): string => {
|
||||
@ -22,32 +20,6 @@ export const useKnowledgeBaseId = (): string => {
|
||||
return knowledgeBaseId || '';
|
||||
};
|
||||
|
||||
export const useDeleteDocumentById = (): {
|
||||
removeDocument: (documentId: string) => Promise<number>;
|
||||
} => {
|
||||
const dispatch = useDispatch();
|
||||
const knowledgeBaseId = useKnowledgeBaseId();
|
||||
const showDeleteConfirm = useShowDeleteConfirm();
|
||||
|
||||
const removeDocument = (documentId: string) => () => {
|
||||
return dispatch({
|
||||
type: 'kFModel/document_rm',
|
||||
payload: {
|
||||
doc_id: documentId,
|
||||
kb_id: knowledgeBaseId,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const onRmDocument = (documentId: string): Promise<number> => {
|
||||
return showDeleteConfirm({ onOk: removeDocument(documentId) });
|
||||
};
|
||||
|
||||
return {
|
||||
removeDocument: onRmDocument,
|
||||
};
|
||||
};
|
||||
|
||||
export const useFetchKnowledgeBaseConfiguration = () => {
|
||||
const knowledgeBaseId = useKnowledgeBaseId();
|
||||
|
||||
@ -132,37 +104,6 @@ export const useDeleteKnowledge = () => {
|
||||
return { data, loading, deleteKnowledge: mutateAsync };
|
||||
};
|
||||
|
||||
export const useSelectFileThumbnails = () => {
|
||||
const fileThumbnails: Record<string, string> = useSelector(
|
||||
(state: any) => state.kFModel.fileThumbnails,
|
||||
);
|
||||
|
||||
return fileThumbnails;
|
||||
};
|
||||
|
||||
export const useFetchFileThumbnails = (docIds?: Array<string>) => {
|
||||
const dispatch = useDispatch();
|
||||
const fileThumbnails = useSelectFileThumbnails();
|
||||
|
||||
const fetchFileThumbnails = useCallback(
|
||||
(docIds: Array<string>) => {
|
||||
dispatch({
|
||||
type: 'kFModel/fetch_document_thumbnails',
|
||||
payload: { doc_ids: docIds.join(',') },
|
||||
});
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (docIds) {
|
||||
fetchFileThumbnails(docIds);
|
||||
}
|
||||
}, [docIds, fetchFileThumbnails]);
|
||||
|
||||
return { fileThumbnails, fetchFileThumbnails };
|
||||
};
|
||||
|
||||
//#region knowledge configuration
|
||||
|
||||
export const useUpdateKnowledge = () => {
|
||||
|
||||
Reference in New Issue
Block a user