import PropTypes from "prop-types"; import { FormattedMessage } from "react-intl"; import { connect } from "react-redux"; import { me } from "flavours/glitch/initial_state"; import { privacyPolicyLink } from "flavours/glitch/utils/backend_links"; import { HASHTAG_PATTERN_REGEX } from "flavours/glitch/utils/hashtags"; import Warning from "../components/warning"; const mapStateToProps = state => ({ needsLockWarning: state.getIn(["compose", "privacy"]) === "private" && !state.getIn(["accounts", me, "locked"]), hashtagWarning: state.getIn(["compose", "privacy"]) !== "public" && HASHTAG_PATTERN_REGEX.test(state.getIn(["compose", "text"])), directMessageWarning: state.getIn(["compose", "privacy"]) === "direct", }); const WarningWrapper = ({ needsLockWarning, hashtagWarning, directMessageWarning }) => { if (needsLockWarning) { return }} />} />; } if (hashtagWarning) { return } />; } if (directMessageWarning) { const message = ( {!!privacyPolicyLink && } ); return ; } return null; }; WarningWrapper.propTypes = { needsLockWarning: PropTypes.bool, hashtagWarning: PropTypes.bool, directMessageWarning: PropTypes.bool, }; export default connect(mapStateToProps)(WarningWrapper);