import React from 'react'; import classNames from 'classnames'; import { Avatar, AvatarSize } from './Avatar'; import { MessageBodyHighlight } from './MessageBodyHighlight'; import { Timestamp } from './conversation/Timestamp'; import { ContactName } from './conversation/ContactName'; import { FindAndFormatContactType, openConversationExternal, PropsForSearchResults, } from '../state/ducks/conversations'; import { useDispatch } from 'react-redux'; type PropsHousekeeping = { isSelected?: boolean; }; type Props = PropsForSearchResults & PropsHousekeeping; const FromName = (props: { from: FindAndFormatContactType; to: FindAndFormatContactType }) => { const { from, to } = props; if (from.isMe && to.isMe) { return ( {window.i18n('noteToSelf')} ); } if (from.isMe) { return {window.i18n('you')}; } return ( // tslint:disable: use-simple-attributes ); }; const From = (props: { from: FindAndFormatContactType; to: FindAndFormatContactType }) => { const { to, from } = props; const fromName = ; if (!to.isMe) { return (
{fromName} {window.i18n('to')}{' '}
); } return
{fromName}
; }; const AvatarItem = (props: { from: FindAndFormatContactType }) => { const { from } = props; const userName = from.profileName || from.phoneNumber; return ( ); }; export const MessageSearchResult = (props: Props) => { const { from, id: messageId, isSelected, conversationId, receivedAt, snippet, to } = props; const dispatch = useDispatch(); if (!from || !to) { return null; } return (
{ dispatch( openConversationExternal({ id: conversationId, messageId, firstUnreadIdOnOpen: undefined, }) ); }} className={classNames( 'module-message-search-result', isSelected ? 'module-message-search-result--is-selected' : null )} >
); };