mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Add TagFeatureItem #4368 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -194,6 +194,7 @@ export const useFetchChunk = (chunkId?: string): ResponseType<any> => {
|
||||
queryKey: ['fetchChunk'],
|
||||
enabled: !!chunkId,
|
||||
initialData: {},
|
||||
gcTime: 0,
|
||||
queryFn: async () => {
|
||||
const data = await kbService.get_chunk({
|
||||
chunk_id: chunkId,
|
||||
|
||||
@ -20,6 +20,7 @@ import {
|
||||
} from '@tanstack/react-query';
|
||||
import { useDebounce } from 'ahooks';
|
||||
import { message } from 'antd';
|
||||
import { useState } from 'react';
|
||||
import { useSearchParams } from 'umi';
|
||||
import { useHandleSearchChange } from './logic-hooks';
|
||||
import { useSetPaginationParams } from './route-hook';
|
||||
@ -34,9 +35,9 @@ export const useKnowledgeBaseId = (): string => {
|
||||
export const useFetchKnowledgeBaseConfiguration = () => {
|
||||
const knowledgeBaseId = useKnowledgeBaseId();
|
||||
|
||||
const { data, isFetching: loading } = useQuery({
|
||||
const { data, isFetching: loading } = useQuery<IKnowledge>({
|
||||
queryKey: ['fetchKnowledgeDetail'],
|
||||
initialData: {},
|
||||
initialData: {} as IKnowledge,
|
||||
gcTime: 0,
|
||||
queryFn: async () => {
|
||||
const { data } = await kbService.get_kb_detail({
|
||||
@ -341,4 +342,24 @@ export const useTagIsRenaming = () => {
|
||||
return useIsMutating({ mutationKey: ['renameTag'] }) > 0;
|
||||
};
|
||||
|
||||
export const useFetchTagListByKnowledgeIds = () => {
|
||||
const [knowledgeIds, setKnowledgeIds] = useState<string[]>([]);
|
||||
|
||||
const { data, isFetching: loading } = useQuery<Array<[string, number]>>({
|
||||
queryKey: ['fetchTagListByKnowledgeIds'],
|
||||
enabled: knowledgeIds.length > 0,
|
||||
initialData: [],
|
||||
gcTime: 0, // https://tanstack.com/query/latest/docs/framework/react/guides/caching?from=reactQueryV3
|
||||
queryFn: async () => {
|
||||
const { data } = await kbService.listTagByKnowledgeIds({
|
||||
kb_ids: knowledgeIds.join(','),
|
||||
});
|
||||
const list = data?.data || [];
|
||||
return list;
|
||||
},
|
||||
});
|
||||
|
||||
return { list: data, loading, setKnowledgeIds };
|
||||
};
|
||||
|
||||
//#endregion
|
||||
|
||||
@ -405,30 +405,6 @@ export interface IRemoveMessageById {
|
||||
removeMessageById(messageId: string): void;
|
||||
}
|
||||
|
||||
export const useRemoveMessageById = (
|
||||
setCurrentConversation: (
|
||||
callback: (state: IClientConversation) => IClientConversation,
|
||||
) => void,
|
||||
) => {
|
||||
const removeMessageById = useCallback(
|
||||
(messageId: string) => {
|
||||
setCurrentConversation((pre) => {
|
||||
const nextMessages =
|
||||
pre.message?.filter(
|
||||
(x) => getMessagePureId(x.id) !== getMessagePureId(messageId),
|
||||
) ?? [];
|
||||
return {
|
||||
...pre,
|
||||
message: nextMessages,
|
||||
};
|
||||
});
|
||||
},
|
||||
[setCurrentConversation],
|
||||
);
|
||||
|
||||
return { removeMessageById };
|
||||
};
|
||||
|
||||
export const useRemoveMessagesAfterCurrentMessage = (
|
||||
setCurrentConversation: (
|
||||
callback: (state: IClientConversation) => IClientConversation,
|
||||
|
||||
Reference in New Issue
Block a user