From 0bc6da89d2c57d3d90d2a71ee7d98d37569449f9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 24 Dec 2016 01:22:47 +0100 Subject: Hide unlisted toggle when private is active, hide nsfw toggle when no files added --- .../javascripts/components/actions/compose.jsx | 4 +-- .../features/compose/components/compose_form.jsx | 33 ++++++++++++++-------- .../compose/containers/compose_form_container.jsx | 5 ++-- 3 files changed, 26 insertions(+), 16 deletions(-) (limited to 'app/assets/javascripts/components') diff --git a/app/assets/javascripts/components/actions/compose.jsx b/app/assets/javascripts/components/actions/compose.jsx index 0e84723b6..05674ba89 100644 --- a/app/assets/javascripts/components/actions/compose.jsx +++ b/app/assets/javascripts/components/actions/compose.jsx @@ -24,7 +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 const COMPOSE_LISTABILITY_CHANGE = 'COMPOSE_LISTABILITY_CHANGE'; export function changeCompose(text) { return { @@ -75,7 +75,7 @@ export function submitCompose() { // To make the app more responsive, immediately get the status into the columns dispatch(updateTimeline('home', { ...response.data })); - if (response.data.in_reply_to_id === null && !getState().getIn(['compose', 'private'])) { + if (response.data.in_reply_to_id === null && !getState().getIn(['compose', 'private']) && !getState().getIn(['compose', 'unlisted'])) { dispatch(updateTimeline('public', { ...response.data })); } }).catch(function (error) { 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 1de3e068b..760b0efd1 100644 --- a/app/assets/javascripts/components/features/compose/components/compose_form.jsx +++ b/app/assets/javascripts/components/features/compose/components/compose_form.jsx @@ -10,6 +10,7 @@ import { debounce } from 'react-decoration'; import UploadButtonContainer from '../containers/upload_button_container'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import Toggle from 'react-toggle'; +import { Motion, spring } from 'react-motion'; const messages = defineMessages({ placeholder: { id: 'compose_form.placeholder', defaultMessage: 'What is on your mind?' }, @@ -24,9 +25,11 @@ const ComposeForm = React.createClass({ suggestions: ImmutablePropTypes.list, sensitive: React.PropTypes.bool, unlisted: React.PropTypes.bool, + private: React.PropTypes.bool, is_submitting: React.PropTypes.bool, is_uploading: React.PropTypes.bool, in_reply_to: ImmutablePropTypes.map, + media_count: React.PropTypes.number, onChange: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired, onCancelReply: React.PropTypes.func.isRequired, @@ -74,7 +77,7 @@ const ComposeForm = React.createClass({ handleChangeVisibility (e) { this.props.onChangeVisibility(e.target.checked); }, - + handleChangeListability (e) { this.props.onChangeListability(e.target.checked); }, @@ -125,18 +128,24 @@ 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 00c641fb9..1d8f20ca7 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)); } -- cgit