DB-GPT/web/pages/mobile/chat/components/Content.tsx
Dreammy23 471689ba20
feat(web): Unified frontend code style (#1923)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: 谨欣 <echo.cmy@antgroup.com>
Co-authored-by: 严志勇 <yanzhiyong@tiansuixiansheng.com>
Co-authored-by: yanzhiyong <932374019@qq.com>
2024-08-30 14:03:06 +08:00

24 lines
683 B
TypeScript

import React, { memo, useContext, useMemo } from 'react';
import { MobileChatContext } from '../';
import ChatDialog from './ChatDialog';
const Content: React.FC = () => {
const { history } = useContext(MobileChatContext);
// 过滤出需要展示的消息
const showMessages = useMemo(() => {
return history.filter(item => ['view', 'human'].includes(item.role));
}, [history]);
return (
<div className='flex flex-col gap-4'>
{!!showMessages.length &&
showMessages.map((message, index) => {
return <ChatDialog key={message.context + index} message={message} index={index} />;
})}
</div>
);
};
export default memo(Content);