mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-13 08:28:22 +08:00
### What problem does this PR solve? Fix: Linter error message: Use 'const' instead. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Updated variable declarations across form components, agent utilities, memory management hooks, and data handling functions to enhance code consistency and maintainability throughout the application codebase. * **Style** * Added ESLint suppressions to document intentional constant-condition patterns in asynchronous event streaming operations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { useHandleSearchChange } from '@/hooks/logic-hooks';
|
|
import { IMemory } from '@/pages/memories/interface';
|
|
import memoryService from '@/services/memory-service';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { useParams, useSearchParams } from 'react-router';
|
|
import { MemoryApiAction } from '../constant';
|
|
|
|
export const useFetchMemoryBaseConfiguration = () => {
|
|
const { id } = useParams();
|
|
const [searchParams] = useSearchParams();
|
|
const memoryBaseId = searchParams.get('id') || id;
|
|
const { handleInputChange, searchString, pagination, setPagination } =
|
|
useHandleSearchChange();
|
|
|
|
const queryKey: (MemoryApiAction | number)[] = [
|
|
MemoryApiAction.FetchMemoryDetail,
|
|
];
|
|
|
|
const { data, isFetching: loading } = useQuery<IMemory>({
|
|
queryKey: [...queryKey, searchString, pagination],
|
|
initialData: {} as IMemory,
|
|
gcTime: 0,
|
|
queryFn: async () => {
|
|
if (memoryBaseId) {
|
|
const { data } = await memoryService.getMemoryConfig(
|
|
memoryBaseId as string,
|
|
);
|
|
return data?.data ?? {};
|
|
} else {
|
|
return {};
|
|
}
|
|
},
|
|
});
|
|
|
|
return {
|
|
data,
|
|
loading,
|
|
handleInputChange,
|
|
searchString,
|
|
pagination,
|
|
setPagination,
|
|
};
|
|
};
|