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:
@ -314,6 +314,10 @@ export const useDeleteMessage = () => {
|
||||
conversationId,
|
||||
});
|
||||
|
||||
if (data.retcode === 0) {
|
||||
message.success(i18n.t(`message.deleted`));
|
||||
}
|
||||
|
||||
return data.retcode;
|
||||
},
|
||||
});
|
||||
|
||||
@ -5,8 +5,10 @@ import { ResponseType } from '@/interfaces/database/base';
|
||||
import { IAnswer } from '@/interfaces/database/chat';
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
||||
import { IClientConversation } from '@/pages/chat/interface';
|
||||
import api from '@/utils/api';
|
||||
import { getAuthorization } from '@/utils/authorization-util';
|
||||
import { getMessagePureId } from '@/utils/chat';
|
||||
import { PaginationProps } from 'antd';
|
||||
import { FormInstance } from 'antd/lib';
|
||||
import axios from 'axios';
|
||||
@ -306,6 +308,34 @@ export const useHandleMessageInputChange = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export interface IRemoveMessageById {
|
||||
removeMessageById(messageId: string): void;
|
||||
}
|
||||
|
||||
export const useRemoveMessageById = (
|
||||
setCurrentConversation: (
|
||||
callback: (state: IClientConversation) => IClientConversation,
|
||||
) => void,
|
||||
) => {
|
||||
const removeMessageById = useCallback(
|
||||
(messageId: string) => {
|
||||
setCurrentConversation((pre) => {
|
||||
const nextMessages =
|
||||
pre.message?.filter(
|
||||
(x) => getMessagePureId(x.id) !== getMessagePureId(messageId),
|
||||
) ?? [];
|
||||
return {
|
||||
...pre,
|
||||
message: nextMessages,
|
||||
};
|
||||
});
|
||||
},
|
||||
[setCurrentConversation],
|
||||
);
|
||||
|
||||
return { removeMessageById };
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user