[feature] Always show spoiler / content-warning box

This commit is contained in:
tobi
2024-12-19 17:16:15 +01:00
parent bf5366e127
commit b16e8bda7d
13 changed files with 9 additions and 98 deletions

View File

@@ -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,

View File

@@ -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 {
<ReplyIndicatorContainer />
<div className={`spoiler-input ${spoiler ? 'spoiler-input--visible' : ''}`} ref={this.setRef} aria-hidden={!this.props.spoiler}>
<div className={'spoiler-input spoiler-input--visible'} ref={this.setRef}>
<AutosuggestInput
placeholder={intl.formatMessage(messages.spoiler_placeholder)}
value={spoilerText}
onChange={this.handleChangeSpoiler}
onKeyDown={this.handleKeyDown}
disabled={!spoiler}
ref={this.handleRefSpoilerText}
suggestions={suggestions}
onSuggestionsFetchRequested={onFetchSuggestions}
@@ -364,11 +359,9 @@ class ComposeForm extends ImmutablePureComponent {
<OptionsContainer
advancedOptions={advancedOptions}
disabled={isSubmitting}
onToggleSpoiler={spoilersAlwaysOn ? null : onChangeSpoilerness}
onUpload={onPaste}
isEditing={isEditing}
sensitive={sensitive || (spoilersAlwaysOn && spoilerText && spoilerText.length > 0)}
spoiler={spoilersAlwaysOn ? (spoilerText && spoilerText.length > 0) : spoiler}
sensitive={sensitive || (spoilerText && spoilerText.length > 0)}
/>
<div className='character-counter__wrapper'>
<CharacterCounter text={countText} max={maxChars} />

View File

@@ -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));
},

View File

@@ -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})`);

View File

@@ -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)