import * as React from 'react'; import { Avatar } from './Avatar'; import { ConfirmationModal } from './ConfirmationModal'; import { InContactsIcon } from './InContactsIcon'; import { ConversationType } from '../state/ducks/conversations'; import { LocalizerType } from '../types/Util'; type SafetyNumberProps = { contactID: string; onClose?: () => void; }; export type Props = { readonly contacts: Array; readonly i18n: LocalizerType; readonly onCancel: () => void; readonly onConfirm: () => void; readonly renderSafetyNumber: (props: SafetyNumberProps) => JSX.Element; }; type SafetyDialogContentProps = Props & { readonly onView: (contact: ConversationType) => void; }; const SafetyDialogContents = ({ contacts, i18n, onCancel, onConfirm, onView, }: SafetyDialogContentProps): JSX.Element => { const cancelButtonRef = React.createRef(); React.useEffect(() => { if (cancelButtonRef && cancelButtonRef.current) { cancelButtonRef.current.focus(); } }, [contacts]); return ( <>

{i18n('safetyNumberChanges')}

{i18n('changedVerificationWarning')}
); }; export const SafetyNumberChangeDialog = (props: Props): JSX.Element => { const { i18n, onCancel, renderSafetyNumber } = props; const [contact, setViewSafetyNumber] = React.useState< ConversationType | undefined >(undefined); const onClose = contact ? () => { setViewSafetyNumber(undefined); } : onCancel; return ( {contact && renderSafetyNumber({ contactID: contact.id, onClose })} {!contact && ( { setViewSafetyNumber(selectedContact); }} /> )} ); };