import { memo } from 'react'; import { ContentTypes } from 'librechat-data-provider'; import type { TMessageContentParts } from 'librechat-data-provider'; import EditTextPart from './Parts/EditTextPart'; import Part from './Part'; type ContentPartsProps = { content: Array | undefined; messageId: string; isCreatedByUser: boolean; isLast: boolean; isSubmitting: boolean; edit?: boolean; enterEdit?: (cancel?: boolean) => void | null | undefined; siblingIdx?: number; setSiblingIdx?: | ((value: number) => void | React.Dispatch>) | null | undefined; }; const ContentParts = memo( ({ content, messageId, isCreatedByUser, isLast, isSubmitting, edit, enterEdit, siblingIdx, setSiblingIdx, }: ContentPartsProps) => { if (!content) { return null; } if (edit === true && enterEdit && setSiblingIdx) { return ( <> {content.map((part, idx) => { if (part?.type !== ContentTypes.TEXT || typeof part.text !== 'string') { return null; } return ( ); })} ); } return ( <> {content .filter((part) => part) .map((part, idx) => ( ))} ); }, ); export default ContentParts;