about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-06-14 12:59:59 +0200
committermultiple creatures <dev@multiple-creature.party>2020-02-22 01:30:54 -0600
commitdcc872198855d773bc1f66e2e575d9ce26da3914 (patch)
tree4508b000a20895898951e859dd8dff1e2a972689 /app/javascript/flavours/glitch
parenta818025c288bb9afa6e1b08c0729558ebb405ed1 (diff)
Fix replying not automatically switching to compose form on mobile
Diffstat (limited to 'app/javascript/flavours/glitch')
-rw-r--r--app/javascript/flavours/glitch/features/compose/components/compose_form.js18
-rw-r--r--app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js10
-rw-r--r--app/javascript/flavours/glitch/features/compose/index.js27
3 files changed, 27 insertions, 28 deletions
diff --git a/app/javascript/flavours/glitch/features/compose/components/compose_form.js b/app/javascript/flavours/glitch/features/compose/components/compose_form.js
index ba768c097..3802ff796 100644
--- a/app/javascript/flavours/glitch/features/compose/components/compose_form.js
+++ b/app/javascript/flavours/glitch/features/compose/components/compose_form.js
@@ -70,8 +70,6 @@ class ComposeForm extends ImmutablePureComponent {
     preselectOnReply: PropTypes.bool,
     onChangeSpoilerness: PropTypes.func,
     onChangeVisibility: PropTypes.func,
-    onMount: PropTypes.func,
-    onUnmount: PropTypes.func,
     onPaste: PropTypes.func,
     onMediaDescriptionConfirm: PropTypes.func,
     account: ImmutablePropTypes.map.isRequired,
@@ -206,22 +204,6 @@ class ComposeForm extends ImmutablePureComponent {
     }
   }
 
-  //  Tells our state the composer has been mounted.
-  componentDidMount () {
-    const { onMount } = this.props;
-    if (onMount) {
-      onMount();
-    }
-  }
-
-  //  Tells our state the composer has been unmounted.
-  componentWillUnmount () {
-    const { onUnmount } = this.props;
-    if (onUnmount) {
-      onUnmount();
-    }
-  }
-
   handleFocus = () => {
     if (this.composeForm) {
       this.composeForm.scrollIntoView();
diff --git a/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js b/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js
index 6d8763d29..2c380be85 100644
--- a/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js
+++ b/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js
@@ -9,10 +9,8 @@ import {
   clearComposeSuggestions,
   fetchComposeSuggestions,
   insertEmojiCompose,
-  mountCompose,
   selectComposeSuggestion,
   submitCompose,
-  unmountCompose,
   uploadCompose,
   resetCompose,
 } from 'flavours/glitch/actions/compose';
@@ -118,14 +116,6 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
     dispatch(changeComposeVisibility(value));
   },
 
-  onMount() {
-    dispatch(mountCompose());
-  },
-
-  onUnmount() {
-    dispatch(unmountCompose());
-  },
-
   onMediaDescriptionConfirm(routerHistory) {
     dispatch(openModal('CONFIRM', {
       message: intl.formatMessage(messages.missingDescriptionMessage),
diff --git a/app/javascript/flavours/glitch/features/compose/index.js b/app/javascript/flavours/glitch/features/compose/index.js
index 7a0b66754..f5faec2d9 100644
--- a/app/javascript/flavours/glitch/features/compose/index.js
+++ b/app/javascript/flavours/glitch/features/compose/index.js
@@ -4,6 +4,7 @@ import NavigationContainer from './containers/navigation_container';
 import PropTypes from 'prop-types';
 import ImmutablePropTypes from 'react-immutable-proptypes';
 import { connect } from 'react-redux';
+import { mountCompose, unmountCompose } from 'flavours/glitch/actions/compose';
 import { injectIntl, defineMessages } from 'react-intl';
 import classNames from 'classnames';
 import SearchContainer from './containers/search_container';
@@ -27,6 +28,14 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
   onClickElefriend () {
     dispatch(cycleElefriendCompose());
   },
+
+  onMount () {
+    dispatch(mountCompose());
+  },
+
+  onUnmount () {
+    dispatch(unmountCompose());
+  },
 });
 
 export default @connect(mapStateToProps, mapDispatchToProps)
@@ -38,9 +47,27 @@ class Compose extends React.PureComponent {
     isSearchPage: PropTypes.bool,
     elefriend: PropTypes.number,
     onClickElefriend: PropTypes.func,
+    onMount: PropTypes.func,
+    onUnmount: PropTypes.func,
     intl: PropTypes.object.isRequired,
   };
 
+  componentDidMount () {
+    const { isSearchPage } = this.props;
+
+    if (!isSearchPage) {
+      this.props.onMount();
+    }
+  }
+
+  componentWillUnmount () {
+    const { isSearchPage } = this.props;
+
+    if (!isSearchPage) {
+      this.props.onUnmount();
+    }
+  }
+
   render () {
     const {
       elefriend,