From e5a05a92107271ea8f24ac9813b511b02c720198 Mon Sep 17 00:00:00 2001 From: 2458773093 <2458773093@protonmail.com> Date: Fri, 23 Aug 2019 02:05:20 +0300 Subject: [PATCH] edit integration --- app/javascript/gabsocial/actions/importer/normalizer.js | 2 +- app/javascript/gabsocial/components/modal_root.js | 6 ++++-- .../gabsocial/features/compose/components/compose_form.js | 7 ++++--- .../features/compose/containers/compose_form_container.js | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/javascript/gabsocial/actions/importer/normalizer.js b/app/javascript/gabsocial/actions/importer/normalizer.js index b6c524ab..40d7abdb 100644 --- a/app/javascript/gabsocial/actions/importer/normalizer.js +++ b/app/javascript/gabsocial/actions/importer/normalizer.js @@ -53,7 +53,7 @@ export function normalizeStatus(status, normalOldStatus) { // Only calculate these values when status first encountered // Otherwise keep the ones already in the reducer - if (normalOldStatus) { + if (normalOldStatus && normalOldStatus.get('content') === normalStatus.content && normalOldStatus.get('spoiler_text') === normalStatus.spoiler_text) { normalStatus.search_index = normalOldStatus.get('search_index'); normalStatus.contentHtml = normalOldStatus.get('contentHtml'); normalStatus.spoilerHtml = normalOldStatus.get('spoilerHtml'); diff --git a/app/javascript/gabsocial/components/modal_root.js b/app/javascript/gabsocial/components/modal_root.js index fcc6278d..45017912 100644 --- a/app/javascript/gabsocial/components/modal_root.js +++ b/app/javascript/gabsocial/components/modal_root.js @@ -10,6 +10,7 @@ const messages = defineMessages({ }); const mapStateToProps = state => ({ + composeId: state.getIn(['compose', 'id']), composeText: state.getIn(['compose', 'text']), }); @@ -30,6 +31,7 @@ class ModalRoot extends React.PureComponent { onOpenModal: PropTypes.func.isRequired, onCancelReplyCompose: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, + composeId: PropTypes.string, composeText: PropTypes.string, type: PropTypes.string, }; @@ -48,9 +50,9 @@ class ModalRoot extends React.PureComponent { } handleOnClose = () => { - const { onOpenModal, composeText, onClose, intl, type, onCancelReplyCompose } = this.props; + const { onOpenModal, composeText, composeId, onClose, intl, type, onCancelReplyCompose } = this.props; - if (composeText && type == 'COMPOSE') { + if (!composeId && composeText && type == 'COMPOSE') { onOpenModal('CONFIRM', { message: , confirm: intl.formatMessage(messages.confirm), diff --git a/app/javascript/gabsocial/features/compose/components/compose_form.js b/app/javascript/gabsocial/features/compose/components/compose_form.js index b507c075..e3d5e5f2 100644 --- a/app/javascript/gabsocial/features/compose/components/compose_form.js +++ b/app/javascript/gabsocial/features/compose/components/compose_form.js @@ -46,6 +46,7 @@ class ComposeForm extends ImmutablePureComponent { static propTypes = { intl: PropTypes.object.isRequired, + edit: PropTypes.bool.isRequired, text: PropTypes.string.isRequired, suggestions: ImmutablePropTypes.list, spoiler: PropTypes.bool, @@ -200,7 +201,7 @@ class ComposeForm extends ImmutablePureComponent { } render () { - const { intl, onPaste, showSearch, anyMedia, shouldCondense, autoFocus, isModalOpen, quoteOfId } = this.props; + const { intl, onPaste, showSearch, anyMedia, shouldCondense, autoFocus, isModalOpen, quoteOfId, edit } = this.props; const condensed = shouldCondense && !this.props.text && !this.state.composeFocused; const disabled = this.props.isSubmitting; const text = [this.props.spoilerText, countableText(this.props.text)].join(''); @@ -267,7 +268,7 @@ class ComposeForm extends ImmutablePureComponent { !condensed &&
- + {!edit && }
} @@ -279,7 +280,7 @@ class ComposeForm extends ImmutablePureComponent {
- + {!edit && }
diff --git a/app/javascript/gabsocial/features/compose/containers/compose_form_container.js b/app/javascript/gabsocial/features/compose/containers/compose_form_container.js index e651a89f..7dc24cd9 100644 --- a/app/javascript/gabsocial/features/compose/containers/compose_form_container.js +++ b/app/javascript/gabsocial/features/compose/containers/compose_form_container.js @@ -12,6 +12,7 @@ import { } from '../../../actions/compose'; const mapStateToProps = state => ({ + edit: state.getIn(['compose', 'id']) !== null, text: state.getIn(['compose', 'text']), suggestions: state.getIn(['compose', 'suggestions']), spoiler: state.getIn(['compose', 'spoiler']),