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 message by id #2088 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { useFeedback } from '@/hooks/chat-hooks';
|
||||
import { useDeleteMessage, useFeedback } from '@/hooks/chat-hooks';
|
||||
import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import { IRemoveMessageById } from '@/hooks/logic-hooks';
|
||||
import { IFeedbackRequestBody } from '@/interfaces/request/chat';
|
||||
import { getMessagePureId } from '@/utils/chat';
|
||||
import { useCallback } from 'react';
|
||||
@ -30,3 +31,22 @@ export const useSendFeedback = (messageId: string) => {
|
||||
showModal,
|
||||
};
|
||||
};
|
||||
|
||||
export const useRemoveMessage = (
|
||||
messageId: string,
|
||||
removeMessageById: IRemoveMessageById['removeMessageById'],
|
||||
) => {
|
||||
const { deleteMessage, loading } = useDeleteMessage();
|
||||
|
||||
const onRemoveMessage = useCallback(async () => {
|
||||
const pureId = getMessagePureId(messageId);
|
||||
if (pureId) {
|
||||
const retcode = await deleteMessage(pureId);
|
||||
if (retcode === 0) {
|
||||
removeMessageById(messageId);
|
||||
}
|
||||
}
|
||||
}, [deleteMessage, messageId, removeMessageById]);
|
||||
|
||||
return { onRemoveMessage, loading };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user