]> cat aescling's git repositories - mastodon.git/commitdiff
Fix replying not automatically switching to compose form on mobile
authorThibaut Girka <thib@sitedethib.com>
Fri, 14 Jun 2019 10:59:59 +0000 (12:59 +0200)
committerThibG <thib@sitedethib.com>
Fri, 14 Jun 2019 18:37:54 +0000 (20:37 +0200)
app/javascript/flavours/glitch/features/compose/components/compose_form.js
app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js
app/javascript/flavours/glitch/features/compose/index.js

index b4b43785a61623a1e0e7f3043572e28c2eed4646..5e73d7651d259285f73202328e39f20de0ee98c4 100644 (file)
@@ -66,8 +66,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,
   };
@@ -196,22 +194,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();
index 814f9a97a5d6e15f3dd6a55dae70d0e81f7a0d54..199d43913c37f04906745397ed5b9dc8a331ae1f 100644 (file)
@@ -9,10 +9,8 @@ import {
   clearComposeSuggestions,
   fetchComposeSuggestions,
   insertEmojiCompose,
-  mountCompose,
   selectComposeSuggestion,
   submitCompose,
-  unmountCompose,
   uploadCompose,
 } from 'flavours/glitch/actions/compose';
 import {
@@ -114,14 +112,6 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
     dispatch(changeComposeVisibility(value));
   },
 
-  onMount() {
-    dispatch(mountCompose());
-  },
-
-  onUnmount() {
-    dispatch(unmountCompose());
-  },
-
   onMediaDescriptionConfirm(routerHistory) {
     dispatch(openModal('CONFIRM', {
       message: intl.formatMessage(messages.missingDescriptionMessage),
index d3070a19917efea197256417b449198ba89ba70d..cb6c54a48bcdbdba2f5303fd643d175dfb932e22 100644 (file)
@@ -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,