From 538d109a8268d639032e432ed6138ed57f35e5ef Mon Sep 17 00:00:00 2001 From: Anthony Bellew Date: Fri, 23 Dec 2016 07:20:16 -0700 Subject: [PATCH 1/2] Re-add unlisted toggle to the UI --- .../javascripts/components/actions/compose.jsx | 10 +++++++++- .../features/compose/components/compose_form.jsx | 14 +++++++++++++- .../compose/containers/compose_form_container.jsx | 8 +++++++- .../javascripts/components/reducers/compose.jsx | 6 +++++- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/components/actions/compose.jsx b/app/assets/javascripts/components/actions/compose.jsx index 9c9ec9ddec..0e84723b60 100644 --- a/app/assets/javascripts/components/actions/compose.jsx +++ b/app/assets/javascripts/components/actions/compose.jsx @@ -24,6 +24,7 @@ export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT'; export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE'; export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE'; +export const COMPOSE_LISTABILITY_CHANGE = 'COMPOSE_LISTABILITY_CHANGE'; export function changeCompose(text) { return { @@ -67,7 +68,7 @@ export function submitCompose() { in_reply_to_id: getState().getIn(['compose', 'in_reply_to'], null), media_ids: getState().getIn(['compose', 'media_attachments']).map(item => item.get('id')), sensitive: getState().getIn(['compose', 'sensitive']), - visibility: getState().getIn(['compose', 'private']) ? 'private' : 'public' + visibility: getState().getIn(['compose', 'private']) ? 'private' : (getState().getIn(['compose', 'unlisted']) ? 'unlisted' : 'public') }).then(function (response) { dispatch(submitComposeSuccess({ ...response.data })); @@ -223,3 +224,10 @@ export function changeComposeVisibility(checked) { checked }; }; + +export function changeComposeListability(checked) { + return { + type: COMPOSE_LISTABILITY_CHANGE, + checked + }; +}; diff --git a/app/assets/javascripts/components/features/compose/components/compose_form.jsx b/app/assets/javascripts/components/features/compose/components/compose_form.jsx index 6a0e6778da..1de3e068ba 100644 --- a/app/assets/javascripts/components/features/compose/components/compose_form.jsx +++ b/app/assets/javascripts/components/features/compose/components/compose_form.jsx @@ -34,7 +34,8 @@ const ComposeForm = React.createClass({ onFetchSuggestions: React.PropTypes.func.isRequired, onSuggestionSelected: React.PropTypes.func.isRequired, onChangeSensitivity: React.PropTypes.func.isRequired, - onChangeVisibility: React.PropTypes.func.isRequired + onChangeVisibility: React.PropTypes.func.isRequired, + onChangeListability: React.PropTypes.func.isRequired, }, mixins: [PureRenderMixin], @@ -73,6 +74,10 @@ const ComposeForm = React.createClass({ handleChangeVisibility (e) { this.props.onChangeVisibility(e.target.checked); }, + + handleChangeListability (e) { + this.props.onChangeListability(e.target.checked); + }, componentDidUpdate (prevProps) { if (prevProps.in_reply_to !== this.props.in_reply_to) { @@ -120,6 +125,13 @@ const ComposeForm = React.createClass({ + + + + - - - + + {({ opacity, height }) => + + } + - + + {({ opacity, height }) => + + } + ); } diff --git a/app/assets/javascripts/components/features/compose/containers/compose_form_container.jsx b/app/assets/javascripts/components/features/compose/containers/compose_form_container.jsx index 00c641fb9e..1d8f20ca75 100644 --- a/app/assets/javascripts/components/features/compose/containers/compose_form_container.jsx +++ b/app/assets/javascripts/components/features/compose/containers/compose_form_container.jsx @@ -26,7 +26,8 @@ const makeMapStateToProps = () => { private: state.getIn(['compose', 'private']), is_submitting: state.getIn(['compose', 'is_submitting']), is_uploading: state.getIn(['compose', 'is_uploading']), - in_reply_to: getStatus(state, state.getIn(['compose', 'in_reply_to'])) + in_reply_to: getStatus(state, state.getIn(['compose', 'in_reply_to'])), + media_count: state.getIn(['compose', 'media_attachments']).size }; }; @@ -66,7 +67,7 @@ const mapDispatchToProps = function (dispatch) { onChangeVisibility (checked) { dispatch(changeComposeVisibility(checked)); }, - + onChangeListability (checked) { dispatch(changeComposeListability(checked)); }