import React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; import { useAppSelector, useCompose } from 'soapbox/hooks'; import { selectOwnAccount } from 'soapbox/selectors'; import Warning from '../components/warning'; const APPROX_HASHTAG_RE = /(?:^|[^/)\w])#(\w*[a-zA-Z·]\w*)/i; interface IWarningWrapper { composeId: string } const WarningWrapper: React.FC = ({ composeId }) => { const compose = useCompose(composeId); const needsLockWarning = useAppSelector((state) => compose.privacy === 'private' && !selectOwnAccount(state)!.locked); const hashtagWarning = (compose.privacy !== 'public' && compose.privacy !== 'group') && APPROX_HASHTAG_RE.test(compose.text); const directMessageWarning = compose.privacy === 'direct'; if (needsLockWarning) { return ( ), }} /> )} /> ); } if (hashtagWarning) { return ( )} /> ); } if (directMessageWarning) { const message = ( ); return ; } return null; }; export default WarningWrapper;