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,11 +1,9 @@
|
||||
import { Authorization } from '@/constants/authorization';
|
||||
import { MessageType } from '@/constants/chat';
|
||||
import { LanguageTranslationMap } from '@/constants/common';
|
||||
import { Pagination } from '@/interfaces/common';
|
||||
import { ResponseType } from '@/interfaces/database/base';
|
||||
import { IAnswer, Message } from '@/interfaces/database/chat';
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
||||
import { IClientConversation, IMessage } from '@/pages/chat/interface';
|
||||
import api from '@/utils/api';
|
||||
import { getAuthorization } from '@/utils/authorization-util';
|
||||
@ -23,45 +21,11 @@ import {
|
||||
useState,
|
||||
} from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useDispatch } from 'umi';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { useSetModalState, useTranslate } from './common-hooks';
|
||||
import { useSetDocumentParser } from './document-hooks';
|
||||
import { useTranslate } from './common-hooks';
|
||||
import { useSetPaginationParams } from './route-hook';
|
||||
import { useOneNamespaceEffectsLoading } from './store-hooks';
|
||||
import { useFetchTenantInfo, useSaveSetting } from './user-setting-hooks';
|
||||
|
||||
export const useChangeDocumentParser = (documentId: string) => {
|
||||
const setDocumentParser = useSetDocumentParser();
|
||||
|
||||
const {
|
||||
visible: changeParserVisible,
|
||||
hideModal: hideChangeParserModal,
|
||||
showModal: showChangeParserModal,
|
||||
} = useSetModalState();
|
||||
const loading = useOneNamespaceEffectsLoading('kFModel', [
|
||||
'document_change_parser',
|
||||
]);
|
||||
|
||||
const onChangeParserOk = useCallback(
|
||||
async (parserId: string, parserConfig: IChangeParserConfigRequestBody) => {
|
||||
const ret = await setDocumentParser(parserId, documentId, parserConfig);
|
||||
if (ret === 0) {
|
||||
hideChangeParserModal();
|
||||
}
|
||||
},
|
||||
[hideChangeParserModal, setDocumentParser, documentId],
|
||||
);
|
||||
|
||||
return {
|
||||
changeParserLoading: loading,
|
||||
onChangeParserOk,
|
||||
changeParserVisible,
|
||||
hideChangeParserModal,
|
||||
showChangeParserModal,
|
||||
};
|
||||
};
|
||||
|
||||
export const useSetSelectedRecord = <T = IKnowledgeFile>() => {
|
||||
const [currentRecord, setCurrentRecord] = useState<T>({} as T);
|
||||
|
||||
@ -170,28 +134,6 @@ export const useGetPagination = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export const useSetPagination = (namespace: string) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const setPagination = useCallback(
|
||||
(pageNumber = 1, pageSize?: number) => {
|
||||
const pagination: Pagination = {
|
||||
current: pageNumber,
|
||||
} as Pagination;
|
||||
if (pageSize) {
|
||||
pagination.pageSize = pageSize;
|
||||
}
|
||||
dispatch({
|
||||
type: `${namespace}/setPagination`,
|
||||
payload: pagination,
|
||||
});
|
||||
},
|
||||
[dispatch, namespace],
|
||||
);
|
||||
|
||||
return setPagination;
|
||||
};
|
||||
|
||||
export interface AppConf {
|
||||
appName: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user