Add opt-in feature to have the spoilers field always on (fixes #634)

master
Thibaut Girka 6 years ago committed by ThibG
parent 1b479f08c5
commit 171e54eb46
  1. 8
      app/javascript/flavours/glitch/features/composer/index.js
  2. 16
      app/javascript/flavours/glitch/features/composer/options/index.js
  3. 8
      app/javascript/flavours/glitch/features/local_settings/page/index.js
  4. 1
      app/javascript/flavours/glitch/reducers/local_settings.js

@ -51,6 +51,7 @@ import { privacyPreference } from 'flavours/glitch/util/privacy_preference';
// State mapping. // State mapping.
function mapStateToProps (state) { function mapStateToProps (state) {
const spoilersAlwaysOn = state.getIn(['local_settings', 'always_show_spoilers_field']);
const inReplyTo = state.getIn(['compose', 'in_reply_to']); const inReplyTo = state.getIn(['compose', 'in_reply_to']);
const replyPrivacy = inReplyTo ? state.getIn(['statuses', inReplyTo, 'visibility']) : null; const replyPrivacy = inReplyTo ? state.getIn(['statuses', inReplyTo, 'visibility']) : null;
const sideArmBasePrivacy = state.getIn(['local_settings', 'side_arm']); const sideArmBasePrivacy = state.getIn(['local_settings', 'side_arm']);
@ -85,12 +86,13 @@ function mapStateToProps (state) {
sideArm: sideArmPrivacy, sideArm: sideArmPrivacy,
sensitive: state.getIn(['compose', 'sensitive']), sensitive: state.getIn(['compose', 'sensitive']),
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']), showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
spoiler: state.getIn(['compose', 'spoiler']), spoiler: spoilersAlwaysOn || state.getIn(['compose', 'spoiler']),
spoilerText: state.getIn(['compose', 'spoiler_text']), spoilerText: state.getIn(['compose', 'spoiler_text']),
suggestionToken: state.getIn(['compose', 'suggestion_token']), suggestionToken: state.getIn(['compose', 'suggestion_token']),
suggestions: state.getIn(['compose', 'suggestions']), suggestions: state.getIn(['compose', 'suggestions']),
text: state.getIn(['compose', 'text']), text: state.getIn(['compose', 'text']),
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0, anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
spoilersAlwaysOn: spoilersAlwaysOn,
}; };
}; };
@ -376,6 +378,7 @@ class Composer extends React.Component {
spoilerText, spoilerText,
suggestions, suggestions,
text, text,
spoilersAlwaysOn,
} = this.props; } = this.props;
let disabledButton = isSubmitting || isUploading || (!!text.length && !text.trim().length && !anyMedia); let disabledButton = isSubmitting || isUploading || (!!text.length && !text.trim().length && !anyMedia);
@ -443,7 +446,7 @@ class Composer extends React.Component {
onDoodleOpen={onOpenDoodleModal} onDoodleOpen={onOpenDoodleModal}
onModalClose={onCloseModal} onModalClose={onCloseModal}
onModalOpen={onOpenActionsModal} onModalOpen={onOpenActionsModal}
onToggleSpoiler={onChangeSpoilerness} onToggleSpoiler={spoilersAlwaysOn ? null : onChangeSpoilerness}
onUpload={onUpload} onUpload={onUpload}
privacy={privacy} privacy={privacy}
resetFileKey={resetFileKey} resetFileKey={resetFileKey}
@ -515,6 +518,7 @@ Composer.propTypes = {
onUnmount: PropTypes.func, onUnmount: PropTypes.func,
onUpload: PropTypes.func, onUpload: PropTypes.func,
anyMedia: PropTypes.bool, anyMedia: PropTypes.bool,
spoilersAlwaysOn: PropTypes.bool,
}; };
// Connecting and export. // Connecting and export.

@ -285,13 +285,15 @@ export default class ComposerOptions extends React.PureComponent {
title={intl.formatMessage(messages.change_privacy)} title={intl.formatMessage(messages.change_privacy)}
value={privacy} value={privacy}
/> />
<TextIconButton {onToggleSpoiler && (
active={spoiler} <TextIconButton
ariaControls='glitch.composer.spoiler.input' active={spoiler}
label='CW' ariaControls='glitch.composer.spoiler.input'
onClick={onToggleSpoiler} label='CW'
title={intl.formatMessage(messages.spoiler)} onClick={onToggleSpoiler}
/> title={intl.formatMessage(messages.spoiler)}
/>
)}
<Dropdown <Dropdown
active={advancedOptions && advancedOptions.some(value => !!value)} active={advancedOptions && advancedOptions.some(value => !!value)}
disabled={disabled} disabled={disabled}

@ -75,6 +75,14 @@ export default class LocalSettingsPage extends React.PureComponent {
</section> </section>
<section> <section>
<h2><FormattedMessage id='settings.compose_box_opts' defaultMessage='Compose box options' /></h2> <h2><FormattedMessage id='settings.compose_box_opts' defaultMessage='Compose box options' /></h2>
<LocalSettingsPageItem
settings={settings}
item={['always_show_spoilers_field']}
id='mastodon-settings--always_show_spoilers_field'
onChange={onChange}
>
<FormattedMessage id='settings.always_show_spoilers_field' defaultMessage='Always enable the Content Warning field' />
</LocalSettingsPageItem>
<LocalSettingsPageItem <LocalSettingsPageItem
settings={settings} settings={settings}
item={['side_arm']} item={['side_arm']}

@ -12,6 +12,7 @@ const initialState = ImmutableMap({
side_arm : 'none', side_arm : 'none',
side_arm_reply_mode : 'keep', side_arm_reply_mode : 'keep',
show_reply_count : false, show_reply_count : false,
always_show_spoilers_field: false,
collapsed : ImmutableMap({ collapsed : ImmutableMap({
enabled : true, enabled : true,
auto : ImmutableMap({ auto : ImmutableMap({

Loading…
Cancel
Save