From f24bca0779e3a7072ef0221e495d5dead1d1fb15 Mon Sep 17 00:00:00 2001 From: Lety Does Stuff Date: Mon, 15 Apr 2024 14:23:42 -0700 Subject: [PATCH] Add a sensitive attachment hint to the compose form --- .../features/compose/containers/warning_container.jsx | 9 ++++++--- app/javascript/mastodon/locales/en.json | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/javascript/mastodon/features/compose/containers/warning_container.jsx b/app/javascript/mastodon/features/compose/containers/warning_container.jsx index 9f9285d74d..88ec216014 100644 --- a/app/javascript/mastodon/features/compose/containers/warning_container.jsx +++ b/app/javascript/mastodon/features/compose/containers/warning_container.jsx @@ -10,15 +10,17 @@ import { HASHTAG_PATTERN_REGEX } from 'mastodon/utils/hashtags'; import Warning from '../components/warning'; const mapStateToProps = state => ({ + sensitiveAttachmentHint: state.getIn(['compose', 'spoiler']) !== false && state.getIn(['compose', 'media_attachments']).size > 0, hashtagWarning: state.getIn(['compose', 'privacy']) !== 'public' && HASHTAG_PATTERN_REGEX.test(state.getIn(['compose', 'text'])), needsLockWarning: state.getIn(['compose', 'privacy']) === 'private' && !state.getIn(['accounts', me, 'locked']), directMessageWarning: state.getIn(['compose', 'privacy']) === 'direct', }); -const WarningWrapper = ({ hashtagWarning, needsLockWarning, directMessageWarning }) => { - if ( hashtagWarning || needsLockWarning || directMessageWarning) { +const WarningWrapper = ({ sensitiveAttachmentHint, hashtagWarning, needsLockWarning, directMessageWarning }) => { + if ( sensitiveAttachmentHint || hashtagWarning || needsLockWarning || directMessageWarning) { const message = ( <> + {sensitiveAttachmentHint && } {hashtagWarning && } {needsLockWarning && }} />} {directMessageWarning && } @@ -31,9 +33,10 @@ const WarningWrapper = ({ hashtagWarning, needsLockWarning, directMessageWarning }; WarningWrapper.propTypes = { + sensitiveAttachmentHint: PropTypes.bool, hashtagWarning: PropTypes.bool, needsLockWarning: PropTypes.bool, directMessageWarning: PropTypes.bool, }; -export default connect(mapStateToProps)(WarningWrapper); +export default connect(mapStateToProps)(WarningWrapper); \ No newline at end of file diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index 881ed19e0e..f3d2b99b2f 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -152,6 +152,7 @@ "compose_form.hashtag_warning": "This post won't be listed under any hashtag as it is not public. Only public posts can be searched by hashtag.", "compose_form.lock_disclaimer": "Your account is not {locked}. Anyone can follow you to view your follower-only posts.", "compose_form.lock_disclaimer.lock": "locked", + "compose_form.sensitive_attachment_hint": "Leave the content warning field empty to mark only the post attachments as sensitive.", "compose_form.placeholder": "What's on your mind?", "compose_form.poll.duration": "Poll duration", "compose_form.poll.multiple": "Multiple choice",