From b16e8bda7dcebb031f81f599d43a7a10e6fee658 Mon Sep 17 00:00:00 2001 From: tobi Date: Thu, 19 Dec 2024 17:16:15 +0100 Subject: [PATCH] [feature] Always show spoiler / content-warning box --- .../flavours/glitch/actions/compose.js | 7 ----- .../compose/components/compose_form.jsx | 13 ++------- .../containers/compose_form_container.js | 5 ---- .../flavours/glitch/features/ui/index.jsx | 7 +---- .../flavours/glitch/reducers/compose.js | 10 ------- app/javascript/mastodon/actions/compose.js | 7 ----- .../compose/components/compose_form.jsx | 8 ++---- .../containers/compose_form_container.js | 1 - .../containers/spoiler_button_container.js | 28 ------------------- app/javascript/mastodon/features/ui/index.jsx | 7 +---- app/javascript/mastodon/locales/en-GB.json | 2 +- app/javascript/mastodon/locales/en.json | 2 +- app/javascript/mastodon/reducers/compose.js | 10 ------- 13 files changed, 9 insertions(+), 98 deletions(-) delete mode 100644 app/javascript/mastodon/features/compose/containers/spoiler_button_container.js diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index f0dff3170e8ff273e82483cafa941b2f9b17442d..c74bf7af9bc72ad849ce747170fb8bcd14229026 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -57,7 +57,6 @@ export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT'; export const COMPOSE_ADVANCED_OPTIONS_CHANGE = 'COMPOSE_ADVANCED_OPTIONS_CHANGE'; export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE'; -export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE'; export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE'; export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE'; export const COMPOSE_LISTABILITY_CHANGE = 'COMPOSE_LISTABILITY_CHANGE'; @@ -745,12 +744,6 @@ export const changeComposeLanguage = language => ({ language, }); -export function changeComposeSpoilerness() { - return { - type: COMPOSE_SPOILERNESS_CHANGE, - }; -} - export function changeComposeSpoilerText(text) { return { type: COMPOSE_SPOILER_TEXT_CHANGE, diff --git a/app/javascript/flavours/glitch/features/compose/components/compose_form.jsx b/app/javascript/flavours/glitch/features/compose/components/compose_form.jsx index 53e1bf79aee5d93e17d38b02e271d9c009cd87fb..c197d0a2187b4d95845d90724cdcc9acd6c06968 100644 --- a/app/javascript/flavours/glitch/features/compose/components/compose_form.jsx +++ b/app/javascript/flavours/glitch/features/compose/components/compose_form.jsx @@ -34,7 +34,7 @@ const messages = defineMessages({ id: 'confirmations.missing_media_description.confirm', defaultMessage: 'Send anyway', }, - spoiler_placeholder: { id: 'compose_form.spoiler_placeholder', defaultMessage: 'Write your warning here' }, + spoiler_placeholder: { id: 'compose_form.spoiler_placeholder', defaultMessage: '(Optional) post title / content warning' }, }); class ComposeForm extends ImmutablePureComponent { @@ -79,7 +79,6 @@ class ComposeForm extends ImmutablePureComponent { spoilersAlwaysOn: PropTypes.bool, mediaDescriptionConfirmation: PropTypes.bool, preselectOnReply: PropTypes.bool, - onChangeSpoilerness: PropTypes.func, onChangeVisibility: PropTypes.func, onMediaDescriptionConfirm: PropTypes.func, }; @@ -292,7 +291,6 @@ class ComposeForm extends ImmutablePureComponent { intl, isSubmitting, layout, - onChangeSpoilerness, onClearSuggestions, onFetchSuggestions, onPaste, @@ -300,10 +298,8 @@ class ComposeForm extends ImmutablePureComponent { sensitive, showSearch, sideArm, - spoiler, spoilerText, suggestions, - spoilersAlwaysOn, isEditing, } = this.props; @@ -315,13 +311,12 @@ class ComposeForm extends ImmutablePureComponent { -
+
0)} - spoiler={spoilersAlwaysOn ? (spoilerText && spoilerText.length > 0) : spoiler} + sensitive={sensitive || (spoilerText && spoilerText.length > 0)} />
diff --git a/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js b/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js index e9724568cdbb950a907a8e887d3f6f28ab8e4149..74ce8fc60d9510f060871a5fcc5727ef427c03d3 100644 --- a/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js +++ b/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js @@ -5,7 +5,6 @@ import { connect } from 'react-redux'; import { changeCompose, changeComposeSpoilerText, - changeComposeSpoilerness, changeComposeVisibility, clearComposeSuggestions, fetchComposeSuggestions, @@ -117,10 +116,6 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ dispatch(insertEmojiCompose(position, emoji)); }, - onChangeSpoilerness() { - dispatch(changeComposeSpoilerness()); - }, - onChangeVisibility(value) { dispatch(changeComposeVisibility(value)); }, diff --git a/app/javascript/flavours/glitch/features/ui/index.jsx b/app/javascript/flavours/glitch/features/ui/index.jsx index 0697cc5e1986de90ff2d8b1b27d8c55f952c015a..7bc5daae1ace9c96596d3314b3641aab0e5154ca 100644 --- a/app/javascript/flavours/glitch/features/ui/index.jsx +++ b/app/javascript/flavours/glitch/features/ui/index.jsx @@ -13,7 +13,7 @@ import { debounce } from 'lodash'; import { HotKeys } from 'react-hotkeys'; import { changeLayout } from 'flavours/glitch/actions/app'; -import { uploadCompose, resetCompose, changeComposeSpoilerness } from 'flavours/glitch/actions/compose'; +import { uploadCompose, resetCompose } from 'flavours/glitch/actions/compose'; import { clearHeight } from 'flavours/glitch/actions/height_cache'; import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'flavours/glitch/actions/markers'; import { expandNotifications, notificationsSetVisibility } from 'flavours/glitch/actions/notifications'; @@ -518,11 +518,6 @@ class UI extends Component { this.props.dispatch(resetCompose()); }; - handleHotkeyToggleComposeSpoilers = e => { - e.preventDefault(); - this.props.dispatch(changeComposeSpoilerness()); - }; - handleHotkeyFocusColumn = e => { const index = (e.key * 1) + 1; // First child is drawer, skip that const column = this.node.querySelector(`.column:nth-child(${index})`); diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 0915ecba0f21bb98e6c3dd305971cfa6de275f14..6072333d62c43c611707a49562b305999cd72d85 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -30,7 +30,6 @@ import { COMPOSE_TAG_HISTORY_UPDATE, COMPOSE_ADVANCED_OPTIONS_CHANGE, COMPOSE_SENSITIVITY_CHANGE, - COMPOSE_SPOILERNESS_CHANGE, COMPOSE_SPOILER_TEXT_CHANGE, COMPOSE_VISIBILITY_CHANGE, COMPOSE_LANGUAGE_CHANGE, @@ -383,15 +382,6 @@ export default function compose(state = initialState, action) { map.set('idempotencyKey', uuid()); }); - case COMPOSE_SPOILERNESS_CHANGE: - return state.withMutations(map => { - map.set('spoiler', !state.get('spoiler')); - map.set('idempotencyKey', uuid()); - - if (!state.get('sensitive') && state.get('media_attachments').size >= 1) { - map.set('sensitive', true); - } - }); case COMPOSE_SPOILER_TEXT_CHANGE: return state .set('spoiler_text', action.text) diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index e68afcbf9de17a06206f9acf95a8e48990c45c8d..48ddf8082af62a8f0845f46f595796aa57ccbae2 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -52,7 +52,6 @@ export const COMPOSE_MOUNT = 'COMPOSE_MOUNT'; export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT'; export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE'; -export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE'; export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE'; export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE'; export const COMPOSE_COMPOSING_CHANGE = 'COMPOSE_COMPOSING_CHANGE'; @@ -733,12 +732,6 @@ export const changeComposeLanguage = language => ({ language, }); -export function changeComposeSpoilerness() { - return { - type: COMPOSE_SPOILERNESS_CHANGE, - }; -} - export function changeComposeSpoilerText(text) { return { type: COMPOSE_SPOILER_TEXT_CHANGE, diff --git a/app/javascript/mastodon/features/compose/components/compose_form.jsx b/app/javascript/mastodon/features/compose/components/compose_form.jsx index 86532cb8fbcce24ada9759e72abd6c776168a2b1..addb3e38149296fdf48568fa16c66fe83ffedb68 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.jsx +++ b/app/javascript/mastodon/features/compose/components/compose_form.jsx @@ -21,7 +21,6 @@ import PollButtonContainer from '../containers/poll_button_container'; import PollFormContainer from '../containers/poll_form_container'; import PrivacyDropdownContainer from '../containers/privacy_dropdown_container'; import ReplyIndicatorContainer from '../containers/reply_indicator_container'; -import SpoilerButtonContainer from '../containers/spoiler_button_container'; import UploadButtonContainer from '../containers/upload_button_container'; import UploadFormContainer from '../containers/upload_form_container'; import WarningContainer from '../containers/warning_container'; @@ -33,7 +32,7 @@ const allowedAroundShortCode = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u20 const messages = defineMessages({ placeholder: { id: 'compose_form.placeholder', defaultMessage: 'What is on your mind?' }, - spoiler_placeholder: { id: 'compose_form.spoiler_placeholder', defaultMessage: 'Write your warning here' }, + spoiler_placeholder: { id: 'compose_form.spoiler_placeholder', defaultMessage: '(Optional) post title / content warning' }, publish: { id: 'compose_form.publish', defaultMessage: 'Promulgate' }, publishLoud: { id: 'compose_form.publish_loud', defaultMessage: '{publish}!' }, saveChanges: { id: 'compose_form.save_changes', defaultMessage: 'Save changes' }, @@ -49,7 +48,6 @@ class ComposeForm extends ImmutablePureComponent { intl: PropTypes.object.isRequired, text: PropTypes.string.isRequired, suggestions: ImmutablePropTypes.list, - spoiler: PropTypes.bool, privacy: PropTypes.string, spoilerText: PropTypes.string, focusDate: PropTypes.instanceOf(Date), @@ -244,13 +242,12 @@ class ComposeForm extends ImmutablePureComponent { -
+
-
diff --git a/app/javascript/mastodon/features/compose/containers/compose_form_container.js b/app/javascript/mastodon/features/compose/containers/compose_form_container.js index ba20698bac8c5c52e61409977bca7cb1264042fb..b3bf71fecf2bdd5c9dba8e82f961b791c072cde5 100644 --- a/app/javascript/mastodon/features/compose/containers/compose_form_container.js +++ b/app/javascript/mastodon/features/compose/containers/compose_form_container.js @@ -15,7 +15,6 @@ import ComposeForm from '../components/compose_form'; const mapStateToProps = state => ({ text: state.getIn(['compose', 'text']), suggestions: state.getIn(['compose', 'suggestions']), - spoiler: state.getIn(['compose', 'spoiler']), spoilerText: state.getIn(['compose', 'spoiler_text']), privacy: state.getIn(['compose', 'privacy']), focusDate: state.getIn(['compose', 'focusDate']), diff --git a/app/javascript/mastodon/features/compose/containers/spoiler_button_container.js b/app/javascript/mastodon/features/compose/containers/spoiler_button_container.js deleted file mode 100644 index b3d7a713355775b14c6efa98ba156f7f9a72e58b..0000000000000000000000000000000000000000 --- a/app/javascript/mastodon/features/compose/containers/spoiler_button_container.js +++ /dev/null @@ -1,28 +0,0 @@ -import { injectIntl, defineMessages } from 'react-intl'; - -import { connect } from 'react-redux'; - -import { changeComposeSpoilerness } from '../../../actions/compose'; -import TextIconButton from '../components/text_icon_button'; - -const messages = defineMessages({ - marked: { id: 'compose_form.spoiler.marked', defaultMessage: 'Text is hidden behind warning' }, - unmarked: { id: 'compose_form.spoiler.unmarked', defaultMessage: 'Text is not hidden' }, -}); - -const mapStateToProps = (state, { intl }) => ({ - label: 'CW', - title: intl.formatMessage(state.getIn(['compose', 'spoiler']) ? messages.marked : messages.unmarked), - active: state.getIn(['compose', 'spoiler']), - ariaControls: 'cw-spoiler-input', -}); - -const mapDispatchToProps = dispatch => ({ - - onClick () { - dispatch(changeComposeSpoilerness()); - }, - -}); - -export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton)); diff --git a/app/javascript/mastodon/features/ui/index.jsx b/app/javascript/mastodon/features/ui/index.jsx index 4211f14e718b01b05588b89d370c33472f21e32e..dabc3f87084ef1f038b8dfc68b7a97082af7b33b 100644 --- a/app/javascript/mastodon/features/ui/index.jsx +++ b/app/javascript/mastodon/features/ui/index.jsx @@ -17,7 +17,7 @@ import { INTRODUCTION_VERSION } from 'mastodon/actions/onboarding'; import PictureInPicture from 'mastodon/features/picture_in_picture'; import { layoutFromWindow } from 'mastodon/is_mobile'; -import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../actions/compose'; +import { uploadCompose, resetCompose } from '../../actions/compose'; import { clearHeight } from '../../actions/height_cache'; import { expandNotifications } from '../../actions/notifications'; import { fetchServer } from '../../actions/server'; @@ -455,11 +455,6 @@ class UI extends PureComponent { this.props.dispatch(resetCompose()); }; - handleHotkeyToggleComposeSpoilers = e => { - e.preventDefault(); - this.props.dispatch(changeComposeSpoilerness()); - }; - handleHotkeyFocusColumn = e => { const index = (e.key * 1) + 1; // First child is drawer, skip that const column = this.node.querySelector(`.column:nth-child(${index})`); diff --git a/app/javascript/mastodon/locales/en-GB.json b/app/javascript/mastodon/locales/en-GB.json index 25bc97d3d01823fdf1948b18ac811a682b8662ed..3c9009571e73ee92e45e76b65af7afe0cf5b88e1 100644 --- a/app/javascript/mastodon/locales/en-GB.json +++ b/app/javascript/mastodon/locales/en-GB.json @@ -159,7 +159,7 @@ "compose_form.sensitive.unmarked": "{count, plural, one {Media is not marked as sensitive} other {Media is not marked as sensitive}}", "compose_form.spoiler.marked": "Remove content warning", "compose_form.spoiler.unmarked": "Add content warning", - "compose_form.spoiler_placeholder": "Write your warning here", + "compose_form.spoiler_placeholder": "(Optional) post title / content warning", "confirmation_modal.cancel": "Cancel", "confirmations.block.block_and_report": "Block & Report", "confirmations.block.confirm": "Block", diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index 74ebe74ec1abe0cc3c406dbdb24429e2aa199be1..1d557a281a9d1a520b8eaa64a512e529c486de3b 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -159,7 +159,7 @@ "compose_form.sensitive.unmarked": "{count, plural, one {Media is not marked as sensitive} other {Media is not marked as sensitive}}", "compose_form.spoiler.marked": "Remove content warning", "compose_form.spoiler.unmarked": "Add content warning", - "compose_form.spoiler_placeholder": "Write your warning here", + "compose_form.spoiler_placeholder": "(Optional) post title / content warning", "confirmation_modal.cancel": "Cancel", "confirmations.block.block_and_report": "Block & Report", "confirmations.block.confirm": "Block", diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index e6b2509f66d2e5633300bfb9d66662df5e0d4869..671ea2f13205095ca07e62e3220af0b3852e6e92 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -28,7 +28,6 @@ import { COMPOSE_SUGGESTION_TAGS_UPDATE, COMPOSE_TAG_HISTORY_UPDATE, COMPOSE_SENSITIVITY_CHANGE, - COMPOSE_SPOILERNESS_CHANGE, COMPOSE_SPOILER_TEXT_CHANGE, COMPOSE_VISIBILITY_CHANGE, COMPOSE_LANGUAGE_CHANGE, @@ -300,15 +299,6 @@ export default function compose(state = initialState, action) { map.set('idempotencyKey', uuid()); }); - case COMPOSE_SPOILERNESS_CHANGE: - return state.withMutations(map => { - map.set('spoiler', !state.get('spoiler')); - map.set('idempotencyKey', uuid()); - - if (!state.get('sensitive') && state.get('media_attachments').size >= 1) { - map.set('sensitive', true); - } - }); case COMPOSE_SPOILER_TEXT_CHANGE: if (!state.get('spoiler')) return state; return state