fix share link chat quote number (#4690)
* fix share link chat quote number * fix ts * usememo
This commit is contained in:
@@ -251,6 +251,7 @@ const ChatItem = (props: Props) => {
|
||||
chatId: chatId,
|
||||
chatItemDataId: chat.dataId,
|
||||
collectionId: collectionId,
|
||||
collectionIdList,
|
||||
sourceId: sourceId || '',
|
||||
sourceName: sourceName || '',
|
||||
datasetId: datasetId || '',
|
||||
@@ -272,11 +273,12 @@ const ChatItem = (props: Props) => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (chat.obj !== ChatRoleEnum.AI) return;
|
||||
eventBus.on(EventNameEnum.openQuoteReader, handleOpenQuoteReader);
|
||||
return () => {
|
||||
eventBus.off(EventNameEnum.openQuoteReader);
|
||||
};
|
||||
}, [handleOpenQuoteReader]);
|
||||
}, [chat.obj, handleOpenQuoteReader]);
|
||||
|
||||
return (
|
||||
<Box
|
||||
|
||||
@@ -29,6 +29,8 @@ import { useTranslation } from 'next-i18next';
|
||||
import { eventBus, EventNameEnum } from '@/web/common/utils/eventbus';
|
||||
import { SelectOptionsComponent, FormInputComponent } from './Interactive/InteractiveComponents';
|
||||
import { extractDeepestInteractive } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { ChatItemContext } from '@/web/core/chat/context/chatItemContext';
|
||||
|
||||
const accordionButtonStyle = {
|
||||
w: 'auto',
|
||||
@@ -88,9 +90,17 @@ const RenderText = React.memo(function RenderText({
|
||||
text
|
||||
}: {
|
||||
showAnimation: boolean;
|
||||
text?: string;
|
||||
text: string;
|
||||
}) {
|
||||
let source = text || '';
|
||||
const isResponseDetail = useContextSelector(ChatItemContext, (v) => v.isResponseDetail);
|
||||
|
||||
const source = useMemo(() => {
|
||||
if (!text) return '';
|
||||
|
||||
// Remove quote references if not showing response detail
|
||||
return isResponseDetail ? text : text.replace(/\[[a-f0-9]{24}\]\(QUOTE\)/g, '');
|
||||
}, [text, isResponseDetail]);
|
||||
|
||||
// First empty line
|
||||
// if (!source && !isLastChild) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user