mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: fetch conversation and delete chat dialog (#69)
* feat: set chat configuration to backend * feat: exclude unEnabled variables * feat: delete chat dialog * feat: fetch conversation
This commit is contained in:
34
web/src/hooks/commonHooks.ts
Normal file
34
web/src/hooks/commonHooks.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
export const useSetModalState = () => {
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
const showModal = () => {
|
||||
setVisible(true);
|
||||
};
|
||||
const hideModal = () => {
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
return { visible, showModal, hideModal };
|
||||
};
|
||||
|
||||
export const useDeepCompareEffect = (
|
||||
effect: React.EffectCallback,
|
||||
deps: React.DependencyList,
|
||||
) => {
|
||||
const ref = useRef<React.DependencyList>();
|
||||
let callback: ReturnType<React.EffectCallback> = () => {};
|
||||
if (!isEqual(deps, ref.current)) {
|
||||
callback = effect();
|
||||
ref.current = deps;
|
||||
}
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
};
|
||||
@ -125,11 +125,18 @@ export const useFetchKnowledgeBaseConfiguration = () => {
|
||||
}, [fetchKnowledgeBaseConfiguration]);
|
||||
};
|
||||
|
||||
export const useFetchKnowledgeList = (): IKnowledge[] => {
|
||||
export const useFetchKnowledgeList = (
|
||||
shouldFilterListWithoutDocument: boolean = false,
|
||||
): IKnowledge[] => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const knowledgeModel = useSelector((state: any) => state.knowledgeModel);
|
||||
const { data = [] } = knowledgeModel;
|
||||
const list = useMemo(() => {
|
||||
return shouldFilterListWithoutDocument
|
||||
? data.filter((x: IKnowledge) => x.doc_num > 0)
|
||||
: data;
|
||||
}, [data, shouldFilterListWithoutDocument]);
|
||||
|
||||
const fetchList = useCallback(() => {
|
||||
dispatch({
|
||||
@ -141,5 +148,5 @@ export const useFetchKnowledgeList = (): IKnowledge[] => {
|
||||
fetchList();
|
||||
}, [fetchList]);
|
||||
|
||||
return data;
|
||||
return list;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user