import React from 'react'; import { useSelector } from 'react-redux'; import { QuoteClickOptions } from '../../../models/messageType'; import { SortedMessageModelProps } from '../../../state/ducks/conversations'; import { getSortedMessagesOfSelectedConversation } from '../../../state/selectors/conversations'; import { DataExtractionNotificationItem, GenericMessageItem, GroupInvitationItem, GroupUpdateItem, TimerNotificationItem, } from './SessionMessagesTypes'; export const SessionMessagesList = (props: { scrollToQuoteMessage: (options: QuoteClickOptions) => Promise; playNextMessage?: (value: number) => void; }) => { const messagesProps = useSelector(getSortedMessagesOfSelectedConversation); let playableMessageIndex = 0; return ( <> {messagesProps.map((messageProps: SortedMessageModelProps, index: number) => { const timerProps = messageProps.propsForTimerNotification; const propsForGroupInvitation = messageProps.propsForGroupInvitation; const propsForDataExtractionNotification = messageProps.propsForDataExtractionNotification; const groupNotificationProps = messageProps.propsForGroupNotification; if (groupNotificationProps) { return ( ); } if (propsForGroupInvitation) { return ( ); } if (propsForDataExtractionNotification) { return ( ); } if (timerProps) { return ( ); } if (!messageProps) { return; } playableMessageIndex++; // firstMessageOfSeries tells us to render the avatar only for the first message // in a series of messages from the same user return ( ); })} ); };