From b8be588b60d94d8c1068f467e82f0f51678db58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 3 May 2022 23:00:07 +0200 Subject: [PATCH] Post editing: Compose improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/actions/compose.js | 4 ++-- .../features/compose/components/privacy_dropdown.js | 7 ++++++- .../features/compose/components/schedule_button.js | 7 ++++++- .../compose/containers/compose_form_container.js | 6 +++--- .../compose/containers/privacy_dropdown_container.js | 1 + .../compose/containers/reply_indicator_container.js | 9 ++------- .../compose/containers/schedule_button_container.js | 1 + 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/soapbox/actions/compose.js b/app/soapbox/actions/compose.js index 6e3e0e7cb..20b0bf77c 100644 --- a/app/soapbox/actions/compose.js +++ b/app/soapbox/actions/compose.js @@ -98,7 +98,7 @@ export const ensureComposeIsVisible = (getState, routerHistory) => { } }; -export function setComposeToStatus(status, text, spoiler_text, content_type) { +export function setComposeToStatus(status, raw_text, spoiler_text, content_type) { return (dispatch, getState) => { const { instance } = getState(); const { explicitAddressing } = getFeatures(instance); @@ -106,7 +106,7 @@ export function setComposeToStatus(status, text, spoiler_text, content_type) { dispatch({ type: COMPOSE_SET_STATUS, status, - text, + raw_text, explicitAddressing, spoiler_text, content_type, diff --git a/app/soapbox/features/compose/components/privacy_dropdown.js b/app/soapbox/features/compose/components/privacy_dropdown.js index 23111ab1b..caf6ae6c6 100644 --- a/app/soapbox/features/compose/components/privacy_dropdown.js +++ b/app/soapbox/features/compose/components/privacy_dropdown.js @@ -34,6 +34,7 @@ class PrivacyDropdownMenu extends React.PureComponent { placement: PropTypes.string.isRequired, onClose: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired, + unavailable: PropTypes.bool, }; state = { @@ -244,9 +245,13 @@ class PrivacyDropdown extends React.PureComponent { } render() { - const { value, intl } = this.props; + const { value, intl, unavailable } = this.props; const { open, placement } = this.state; + if (unavailable) { + return null; + } + const valueOption = this.options.find(item => item.value === value); return ( diff --git a/app/soapbox/features/compose/components/schedule_button.js b/app/soapbox/features/compose/components/schedule_button.js index af2fb5598..484174355 100644 --- a/app/soapbox/features/compose/components/schedule_button.js +++ b/app/soapbox/features/compose/components/schedule_button.js @@ -16,6 +16,7 @@ class ScheduleButton extends React.PureComponent { static propTypes = { disabled: PropTypes.bool, active: PropTypes.bool, + unavailable: PropTypes.bool, onClick: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; @@ -25,7 +26,11 @@ class ScheduleButton extends React.PureComponent { } render() { - const { intl, active, disabled } = this.props; + const { intl, active, unavailable, disabled } = this.props; + + if (unavailable) { + return null; + } return ( { diff --git a/app/soapbox/features/compose/containers/privacy_dropdown_container.js b/app/soapbox/features/compose/containers/privacy_dropdown_container.js index 3cea17e9d..6f74a0293 100644 --- a/app/soapbox/features/compose/containers/privacy_dropdown_container.js +++ b/app/soapbox/features/compose/containers/privacy_dropdown_container.js @@ -8,6 +8,7 @@ import PrivacyDropdown from '../components/privacy_dropdown'; const mapStateToProps = state => ({ isModalOpen: Boolean(state.get('modals').size && state.get('modals').last().modalType === 'ACTIONS'), value: state.getIn(['compose', 'privacy']), + unavailable: !!state.getIn(['compose', 'id']), }); const mapDispatchToProps = dispatch => ({ diff --git a/app/soapbox/features/compose/containers/reply_indicator_container.js b/app/soapbox/features/compose/containers/reply_indicator_container.js index 1bcf243cc..19a80c7bb 100644 --- a/app/soapbox/features/compose/containers/reply_indicator_container.js +++ b/app/soapbox/features/compose/containers/reply_indicator_container.js @@ -8,13 +8,8 @@ const makeMapStateToProps = () => { const getStatus = makeGetStatus(); const mapStateToProps = state => { - let statusId = state.getIn(['compose', 'id'], null); - let editing = true; - - if (statusId === null) { - statusId = state.getIn(['compose', 'in_reply_to']); - editing = false; - } + const statusId = state.getIn(['compose', 'in_reply_to']); + const editing = !!state.getIn(['compose', 'id']); return { status: getStatus(state, { id: statusId }), diff --git a/app/soapbox/features/compose/containers/schedule_button_container.js b/app/soapbox/features/compose/containers/schedule_button_container.js index 6076220a4..3fce8b22d 100644 --- a/app/soapbox/features/compose/containers/schedule_button_container.js +++ b/app/soapbox/features/compose/containers/schedule_button_container.js @@ -5,6 +5,7 @@ import ScheduleButton from '../components/schedule_button'; const mapStateToProps = state => ({ active: state.getIn(['compose', 'schedule']) ? true : false, + unavailable: !!state.getIn(['compose', 'id']), }); const mapDispatchToProps = dispatch => ({