From 9b666115408b1c81dc958b25573c8ff1f2f35ad3 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 28 Jul 2020 10:50:51 -0500 Subject: [PATCH 1/3] Revert "Merge branch 'patch-1' into 'develop'" This reverts commit 20bfeb1db6cfc20a2d5a305d5c392c3dcf1e60e2, reversing changes made to 475881e80bb69cff2f3512987460b00de146453c. --- app/soapbox/reducers/__tests__/compose-test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/soapbox/reducers/__tests__/compose-test.js b/app/soapbox/reducers/__tests__/compose-test.js index c3ebe7ded..d5306aa33 100644 --- a/app/soapbox/reducers/__tests__/compose-test.js +++ b/app/soapbox/reducers/__tests__/compose-test.js @@ -168,8 +168,20 @@ describe('compose reducer', () => { }); }); + //Remove this test once spoiler is decoupled from marking media as sensitive + it('should handle COMPOSE_SENSITIVITY_CHANGE on Mark Sensitive click, don\'t toggle if spoiler active', () => { + const state = ImmutableMap({ spoiler: true, sensitive: true, idempotencyKey: null }); + const action = { + type: actions.COMPOSE_SENSITIVITY_CHANGE, + }; + expect(reducer(state, action).toJS()).toMatchObject({ + sensitive: true, + }); + }); + + //Edit this test to not pass spoiler state once spoiler is decoupled from marking media as sensitive it('should handle COMPOSE_SENSITIVITY_CHANGE on Mark Sensitive click, toggle if spoiler inactive', () => { - const state = ImmutableMap({ sensitive: true }); + const state = ImmutableMap({ spoiler: false, sensitive: true }); const action = { type: actions.COMPOSE_SENSITIVITY_CHANGE, }; From 2aca716cfab5fc60dfbc4c99764707c88949386d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 28 Jul 2020 10:52:29 -0500 Subject: [PATCH 2/3] Revert "Merge branch 'decouple_spoiler_from_nsfw' into 'develop'" This reverts commit 03c2a8f29456f41eb6c1a1350fb8044c57b6693a, reversing changes made to b6c0884a1dacd86e5ae07f032f8601cb67dbad29. --- .../compose/containers/sensitive_button_container.js | 5 ++++- app/soapbox/reducers/compose.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/soapbox/features/compose/containers/sensitive_button_container.js b/app/soapbox/features/compose/containers/sensitive_button_container.js index dc98de561..3497c0009 100644 --- a/app/soapbox/features/compose/containers/sensitive_button_container.js +++ b/app/soapbox/features/compose/containers/sensitive_button_container.js @@ -12,6 +12,7 @@ const messages = defineMessages({ const mapStateToProps = state => ({ active: state.getIn(['compose', 'sensitive']), + disabled: state.getIn(['compose', 'spoiler']), }); const mapDispatchToProps = dispatch => ({ @@ -26,12 +27,13 @@ class SensitiveButton extends React.PureComponent { static propTypes = { active: PropTypes.bool, + disabled: PropTypes.bool, onClick: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; render() { - const { active, onClick, intl } = this.props; + const { active, disabled, onClick, intl } = this.props; return (
@@ -41,6 +43,7 @@ class SensitiveButton extends React.PureComponent { type='checkbox' checked={active} onChange={onClick} + disabled={disabled} /> diff --git a/app/soapbox/reducers/compose.js b/app/soapbox/reducers/compose.js index c2e39e866..d9d554d47 100644 --- a/app/soapbox/reducers/compose.js +++ b/app/soapbox/reducers/compose.js @@ -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')) { + if (prevSize === 0 && (state.get('default_sensitive') || state.get('spoiler'))) { map.set('sensitive', true); } }); @@ -211,7 +211,9 @@ export default function compose(state = initialState, action) { .set('is_composing', false); case COMPOSE_SENSITIVITY_CHANGE: return state.withMutations(map => { - map.set('sensitive', !state.get('sensitive')); + if (!state.get('spoiler')) { + map.set('sensitive', !state.get('sensitive')); + } map.set('idempotencyKey', uuid()); }); @@ -220,6 +222,10 @@ 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 From 665a27d4c92bd6da05970040c0d9ba1d426a0083 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 28 Jul 2020 10:57:20 -0500 Subject: [PATCH 3/3] Update compose CW tests --- app/soapbox/reducers/__tests__/compose-test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/soapbox/reducers/__tests__/compose-test.js b/app/soapbox/reducers/__tests__/compose-test.js index d5306aa33..d063bc77e 100644 --- a/app/soapbox/reducers/__tests__/compose-test.js +++ b/app/soapbox/reducers/__tests__/compose-test.js @@ -168,7 +168,6 @@ describe('compose reducer', () => { }); }); - //Remove this test once spoiler is decoupled from marking media as sensitive it('should handle COMPOSE_SENSITIVITY_CHANGE on Mark Sensitive click, don\'t toggle if spoiler active', () => { const state = ImmutableMap({ spoiler: true, sensitive: true, idempotencyKey: null }); const action = { @@ -179,7 +178,6 @@ describe('compose reducer', () => { }); }); - //Edit this test to not pass spoiler state once spoiler is decoupled from marking media as sensitive it('should handle COMPOSE_SENSITIVITY_CHANGE on Mark Sensitive click, toggle if spoiler inactive', () => { const state = ImmutableMap({ spoiler: false, sensitive: true }); const action = {