mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Delete or filter conversations #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
14
web/src/hooks/logic-hooks/use-change-search.ts
Normal file
14
web/src/hooks/logic-hooks/use-change-search.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
export const useHandleSearchStrChange = () => {
|
||||
const [searchString, setSearchString] = useState('');
|
||||
const handleInputChange = useCallback(
|
||||
(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||
const value = e.target.value;
|
||||
setSearchString(value);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
return { handleInputChange, searchString };
|
||||
};
|
||||
@ -17,6 +17,7 @@ import {
|
||||
useGetPaginationWithRouter,
|
||||
useHandleSearchChange,
|
||||
} from './logic-hooks';
|
||||
import { useHandleSearchStrChange } from './logic-hooks/use-change-search';
|
||||
|
||||
export const enum ChatApiAction {
|
||||
FetchDialogList = 'fetchDialogList',
|
||||
@ -229,6 +230,9 @@ export const useClickConversationCard = () => {
|
||||
export const useFetchConversationList = () => {
|
||||
const { id } = useParams();
|
||||
const { handleClickConversation } = useClickConversationCard();
|
||||
|
||||
const { searchString, handleInputChange } = useHandleSearchStrChange();
|
||||
|
||||
const {
|
||||
data,
|
||||
isFetching: loading,
|
||||
@ -239,6 +243,11 @@ export const useFetchConversationList = () => {
|
||||
gcTime: 0,
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !!id,
|
||||
select(data) {
|
||||
return searchString
|
||||
? data.filter((x) => x.name.includes(searchString))
|
||||
: data;
|
||||
},
|
||||
queryFn: async () => {
|
||||
const { data } = await chatService.listConversation(
|
||||
{ params: { dialog_id: id } },
|
||||
@ -255,7 +264,7 @@ export const useFetchConversationList = () => {
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading, refetch };
|
||||
return { data, loading, refetch, searchString, handleInputChange };
|
||||
};
|
||||
|
||||
export const useFetchConversation = () => {
|
||||
|
||||
Reference in New Issue
Block a user