import React from 'react'; import { LocalizerType } from '../../types/Util'; import { Message, Props as AllMessageProps, PropsActions as MessageActionsType, PropsData as MessageProps, } from './Message'; import { CallingNotification, PropsData as CallingNotificationProps, } from './CallingNotification'; import { InlineNotificationWrapper } from './InlineNotificationWrapper'; import { PropsActions as UnsupportedMessageActionsType, PropsData as UnsupportedMessageProps, UnsupportedMessage, } from './UnsupportedMessage'; import { PropsData as TimerNotificationProps, TimerNotification, } from './TimerNotification'; import { PropsActions as SafetyNumberActionsType, PropsData as SafetyNumberNotificationProps, SafetyNumberNotification, } from './SafetyNumberNotification'; import { PropsData as VerificationNotificationProps, VerificationNotification, } from './VerificationNotification'; import { GroupNotification, PropsData as GroupNotificationProps, } from './GroupNotification'; import { ResetSessionNotification } from './ResetSessionNotification'; type CallHistoryType = { type: 'callHistory'; data: CallingNotificationProps; }; type LinkNotificationType = { type: 'linkNotification'; data: null; }; type MessageType = { type: 'message'; data: MessageProps; }; type UnsupportedMessageType = { type: 'unsupportedMessage'; data: UnsupportedMessageProps; }; type TimerNotificationType = { type: 'timerNotification'; data: TimerNotificationProps; }; type SafetyNumberNotificationType = { type: 'safetyNumberNotification'; data: SafetyNumberNotificationProps; }; type VerificationNotificationType = { type: 'verificationNotification'; data: VerificationNotificationProps; }; type GroupNotificationType = { type: 'groupNotification'; data: GroupNotificationProps; }; type ResetSessionNotificationType = { type: 'resetSessionNotification'; data: null; }; export type TimelineItemType = | CallHistoryType | LinkNotificationType | MessageType | ResetSessionNotificationType | SafetyNumberNotificationType | TimerNotificationType | UnsupportedMessageType | VerificationNotificationType | GroupNotificationType; type PropsLocalType = { conversationId: string; conversationAccepted: boolean; item?: TimelineItemType; id: string; isSelected: boolean; selectMessage: (messageId: string, conversationId: string) => unknown; i18n: LocalizerType; }; type PropsActionsType = MessageActionsType & UnsupportedMessageActionsType & SafetyNumberActionsType; export type PropsType = PropsLocalType & PropsActionsType & Pick; export class TimelineItem extends React.PureComponent { public render() { const { conversationId, id, isSelected, item, i18n, selectMessage, } = this.props; if (!item) { // tslint:disable-next-line:no-console console.warn(`TimelineItem: item ${id} provided was falsey`); return null; } if (item.type === 'message') { return ; } let notification; if (item.type === 'unsupportedMessage') { notification = ( ); } else if (item.type === 'callHistory') { notification = ; } else if (item.type === 'linkNotification') { notification = (
{i18n('messageHistoryUnsynced')}
); } else if (item.type === 'timerNotification') { notification = ( ); } else if (item.type === 'safetyNumberNotification') { notification = ( ); } else if (item.type === 'verificationNotification') { notification = ( ); } else if (item.type === 'groupNotification') { notification = ( ); } else if (item.type === 'resetSessionNotification') { notification = ( ); } else { throw new Error('TimelineItem: Unknown type!'); } return ( {notification} ); } }