mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: In order to distinguish the keys of a pair of messages, add a prefix to the id when rendering the message. #4409 (#4451)
### What problem does this PR solve? Fix: In order to distinguish the keys of a pair of messages, add a prefix to the id when rendering the message. #4409 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -7,7 +7,7 @@ import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { IClientConversation, IMessage } from '@/pages/chat/interface';
|
||||
import api from '@/utils/api';
|
||||
import { getAuthorization } from '@/utils/authorization-util';
|
||||
import { buildMessageUuid, getMessagePureId } from '@/utils/chat';
|
||||
import { buildMessageUuid } from '@/utils/chat';
|
||||
import { PaginationProps, message } from 'antd';
|
||||
import { FormInstance } from 'antd/lib';
|
||||
import axios from 'axios';
|
||||
@ -309,7 +309,9 @@ export const useSelectDerivedMessages = () => {
|
||||
...pre,
|
||||
{
|
||||
...message,
|
||||
id: buildMessageUuid(message),
|
||||
id: buildMessageUuid(message), // The message id is generated on the front end,
|
||||
// and the message id returned by the back end is the same as the question id,
|
||||
// so that the pair of messages can be deleted together when deleting the message
|
||||
},
|
||||
{
|
||||
role: MessageType.Assistant,
|
||||
@ -353,10 +355,7 @@ export const useSelectDerivedMessages = () => {
|
||||
const removeMessageById = useCallback(
|
||||
(messageId: string) => {
|
||||
setDerivedMessages((pre) => {
|
||||
const nextMessages =
|
||||
pre?.filter(
|
||||
(x) => getMessagePureId(x.id) !== getMessagePureId(messageId),
|
||||
) ?? [];
|
||||
const nextMessages = pre?.filter((x) => x.id !== messageId) ?? [];
|
||||
return nextMessages;
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user