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:
balibabu
2025-01-13 10:51:59 +08:00
committed by GitHub
parent 95261f17f6
commit 2c7ba90cb4
6 changed files with 23 additions and 26 deletions

View File

@ -2,7 +2,6 @@ import { useDeleteMessage, useFeedback } from '@/hooks/chat-hooks';
import { useSetModalState } from '@/hooks/common-hooks';
import { IRemoveMessageById, useSpeechWithSse } from '@/hooks/logic-hooks';
import { IFeedbackRequestBody } from '@/interfaces/request/chat';
import { getMessagePureId } from '@/utils/chat';
import { hexStringToUint8Array } from '@/utils/common-util';
import { SpeechPlayer } from 'openai-speech-stream-player';
import { useCallback, useEffect, useRef, useState } from 'react';
@ -15,7 +14,7 @@ export const useSendFeedback = (messageId: string) => {
async (params: IFeedbackRequestBody) => {
const ret = await feedback({
...params,
messageId: getMessagePureId(messageId),
messageId: messageId,
});
if (ret === 0) {
@ -41,9 +40,8 @@ export const useRemoveMessage = (
const { deleteMessage, loading } = useDeleteMessage();
const onRemoveMessage = useCallback(async () => {
const pureId = getMessagePureId(messageId);
if (pureId) {
const code = await deleteMessage(pureId);
if (messageId) {
const code = await deleteMessage(messageId);
if (code === 0) {
removeMessageById?.(messageId);
}