From 1924a71b5aaa2f32015f3f3a7ee56bb54195f56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 23 Sep 2017 23:38:24 +0200 Subject: [PATCH] Make secondary toot button work nicer with file attachments & revert to the original behavior if it's disabled --- .../compose/components/compose_form.js | 44 ++++++++++++------- .../containers/compose_form_container.js | 1 + app/javascript/styles/components.scss | 1 - 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index 1d60ffe83..56d494dcd 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -58,6 +58,7 @@ export default class ComposeForm extends ImmutablePureComponent { onPickEmoji: PropTypes.func.isRequired, showSearch: PropTypes.bool, settings : ImmutablePropTypes.map.isRequired, + filesAttached : PropTypes.bool, }; static defaultProps = { @@ -159,13 +160,14 @@ export default class ComposeForm extends ImmutablePureComponent { } render () { - const { intl, onPaste, showSearch } = this.props; + const { intl, onPaste, showSearch, filesAttached } = this.props; const disabled = this.props.is_submitting; const maybeEye = (this.props.advanced_options && this.props.advanced_options.do_not_federate) ? ' 👁️' : ''; const text = [this.props.spoiler_text, countableText(this.props.text), maybeEye].join(''); - const sideArmVisibility = this.props.settings.get('side_arm'); - let showSideArm = sideArmVisibility !== 'none'; + const secondaryVisibility = this.props.settings.get('side_arm'); + const isWideView = this.props.settings.get('stretch'); + let showSideArm = secondaryVisibility !== 'none'; let publishText = ''; @@ -177,25 +179,35 @@ export default class ComposeForm extends ImmutablePureComponent { direct: 'envelope', }; - publishText = ( - - { - (this.props.settings.get('stretch') || !showSideArm) ? + if (showSideArm) { + publishText = ( + + { : - '' - } - {intl.formatMessage(messages.publish)} - - ); + style={{ + paddingRight: (filesAttached || !isWideView) ? '0' : '5px', + }} + /> + }{ + (filesAttached || !isWideView) ? '' : + intl.formatMessage(messages.publish) + } + + ); + } else { + if (this.props.privacy === 'private' || this.props.privacy === 'direct') { + publishText = {intl.formatMessage(messages.publish)}; + } else { + publishText = this.props.privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: intl.formatMessage(messages.publish) }) : intl.formatMessage(messages.publish); + } + } // side-arm let publishText2 = ( ); diff --git a/app/javascript/mastodon/features/compose/containers/compose_form_container.js b/app/javascript/mastodon/features/compose/containers/compose_form_container.js index 4e8cd2279..ffa0a3442 100644 --- a/app/javascript/mastodon/features/compose/containers/compose_form_container.js +++ b/app/javascript/mastodon/features/compose/containers/compose_form_container.js @@ -26,6 +26,7 @@ const mapStateToProps = state => ({ me: state.getIn(['compose', 'me']), showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']), settings: state.get('local_settings'), + filesAttached: state.getIn(['compose', 'media_attachments']).size > 0, }); const mapDispatchToProps = (dispatch) => ({ diff --git a/app/javascript/styles/components.scss b/app/javascript/styles/components.scss index 2639fd41e..af85b6b50 100644 --- a/app/javascript/styles/components.scss +++ b/app/javascript/styles/components.scss @@ -433,7 +433,6 @@ padding: 0 !important; width: 4em; text-align: center; - opacity: .8; margin-right: 2px; }