Skip to content

Commit

Permalink
feat: The same query conditions on the search page should not request…
Browse files Browse the repository at this point in the history
… the interface every time the mind map drawer is opened. infiniflow#2759 (infiniflow#2760)

### What problem does this PR solve?

feat: The same query conditions on the search page should not request
the interface every time the mind map drawer is opened. infiniflow#2759

### Type of change

- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):
  • Loading branch information
cike8899 authored Oct 9, 2024
1 parent 945db06 commit 7e5ea24
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions web/src/pages/search/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@/hooks/logic-hooks';
import { IAnswer } from '@/interfaces/database/chat';
import api from '@/utils/api';
import { get, isEmpty, trim } from 'lodash';
import { get, isEmpty, isEqual, trim } from 'lodash';
import {
ChangeEventHandler,
useCallback,
Expand Down Expand Up @@ -188,6 +188,7 @@ export const useTestRetrieval = (

export const useShowMindMapDrawer = (kbIds: string[], question: string) => {
const { visible, showModal, hideModal } = useSetModalState();
const ref = useRef<any>();

const {
fetchMindMap,
Expand All @@ -196,7 +197,14 @@ export const useShowMindMapDrawer = (kbIds: string[], question: string) => {
} = useFetchMindMap();

const handleShowModal = useCallback(() => {
fetchMindMap({ question: trim(question), kb_ids: kbIds });
const searchParams = { question: trim(question), kb_ids: kbIds };
if (
!isEmpty(searchParams.question) &&
!isEqual(searchParams, ref.current)
) {
ref.current = searchParams;
fetchMindMap(searchParams);
}
showModal();
}, [fetchMindMap, showModal, question, kbIds]);

Expand Down

0 comments on commit 7e5ea24

Please sign in to comment.