Merge branch 'decouple_spoiler_from_nsfw' into 'develop'

Update compose.js to decouple spoiler from marking media as NSFW. Fixes #209

Closes #209

See merge request soapbox-pub/soapbox-fe!90
This commit is contained in:
Alex Gleason 2020-07-11 19:36:22 +00:00
commit 03c2a8f294
2 changed files with 3 additions and 12 deletions

View file

@ -12,7 +12,6 @@ const messages = defineMessages({
const mapStateToProps = state => ({
active: state.getIn(['compose', 'sensitive']),
disabled: state.getIn(['compose', 'spoiler']),
});
const mapDispatchToProps = dispatch => ({
@ -27,13 +26,12 @@ class SensitiveButton extends React.PureComponent {
static propTypes = {
active: PropTypes.bool,
disabled: PropTypes.bool,
onClick: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
render() {
const { active, disabled, onClick, intl } = this.props;
const { active, onClick, intl } = this.props;
return (
<div className='compose-form__sensitive-button'>
@ -43,7 +41,6 @@ class SensitiveButton extends React.PureComponent {
type='checkbox'
checked={active}
onChange={onClick}
disabled={disabled}
/>
<span className={classNames('checkbox', { active })} />

View file

@ -114,7 +114,7 @@ function appendMedia(state, media) {
map.set('resetFileKey', Math.floor((Math.random() * 0x10000)));
map.set('idempotencyKey', uuid());
if (prevSize === 0 && (state.get('default_sensitive') || state.get('spoiler'))) {
if (prevSize === 0 && state.get('default_sensitive')) {
map.set('sensitive', true);
}
});
@ -211,9 +211,7 @@ export default function compose(state = initialState, action) {
.set('is_composing', false);
case COMPOSE_SENSITIVITY_CHANGE:
return state.withMutations(map => {
if (!state.get('spoiler')) {
map.set('sensitive', !state.get('sensitive'));
}
map.set('sensitive', !state.get('sensitive'));
map.set('idempotencyKey', uuid());
});
@ -222,10 +220,6 @@ export default function compose(state = initialState, action) {
map.set('spoiler_text', '');
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