// Copyright 2019-2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import classNames from 'classnames'; import { Avatar } from './Avatar'; import { MessageBodyHighlight } from './MessageBodyHighlight'; import { Timestamp } from './conversation/Timestamp'; import { ContactName } from './conversation/ContactName'; import { LocalizerType } from '../types/Util'; import { ColorType } from '../types/Colors'; export type PropsDataType = { isSelected?: boolean; isSearchingInConversation?: boolean; id: string; conversationId: string; sentAt: number; snippet: string; from: { phoneNumber?: string; title: string; isMe?: boolean; name?: string; color?: ColorType; profileName?: string; avatarPath?: string; }; to: { groupName?: string; phoneNumber?: string; title: string; isMe?: boolean; name?: string; profileName?: string; }; }; type PropsHousekeepingType = { i18n: LocalizerType; openConversationInternal: ( conversationId: string, messageId?: string ) => void; }; export type PropsType = PropsDataType & PropsHousekeepingType; export class MessageSearchResult extends React.PureComponent { public renderFromName(): JSX.Element { const { from, i18n, to } = this.props; if (from.isMe && to.isMe) { return ( {i18n('noteToSelf')} ); } if (from.isMe) { return ( {i18n('you')} ); } return ( ); } public renderFrom(): JSX.Element { const { i18n, to, isSearchingInConversation } = this.props; const fromName = this.renderFromName(); if (!to.isMe && !isSearchingInConversation) { return (
{fromName} {i18n('toJoiner')}{' '}
); } return (
{fromName}
); } public renderAvatar(): JSX.Element { const { from, i18n, to } = this.props; const isNoteToSelf = from.isMe && to.isMe; return ( ); } public render(): JSX.Element | null { const { from, i18n, id, isSelected, conversationId, openConversationInternal, sentAt, snippet, to, } = this.props; if (!from || !to) { return null; } return ( ); } }