mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-03 22:30:31 +08:00
30 lines
680 B
TypeScript
30 lines
680 B
TypeScript
import { IDialog } from '@/interfaces/database/chat';
|
|
import { useCallback, useEffect } from 'react';
|
|
import { useDispatch, useSelector } from 'umi';
|
|
|
|
export const useFetchDialogList = () => {
|
|
const dispatch = useDispatch();
|
|
const dialogList: IDialog[] = useSelector(
|
|
(state: any) => state.chatModel.dialogList,
|
|
);
|
|
|
|
useEffect(() => {
|
|
dispatch({ type: 'chatModel/listDialog' });
|
|
}, [dispatch]);
|
|
|
|
return dialogList;
|
|
};
|
|
|
|
export const useSetDialog = () => {
|
|
const dispatch = useDispatch();
|
|
|
|
const setDialog = useCallback(
|
|
(payload: IDialog) => {
|
|
dispatch({ type: 'chatModel/setDialog', payload });
|
|
},
|
|
[dispatch],
|
|
);
|
|
|
|
return setDialog;
|
|
};
|