Fix replying not automatically switching to compose form on mobile

This commit is contained in:
Thibaut Girka 2019-06-14 12:59:59 +02:00 committed by ThibG
parent c0e5f32d13
commit e433386545
3 changed files with 27 additions and 28 deletions

View file

@ -66,8 +66,6 @@ class ComposeForm extends ImmutablePureComponent {
preselectOnReply: PropTypes.bool, preselectOnReply: PropTypes.bool,
onChangeSpoilerness: PropTypes.func, onChangeSpoilerness: PropTypes.func,
onChangeVisibility: PropTypes.func, onChangeVisibility: PropTypes.func,
onMount: PropTypes.func,
onUnmount: PropTypes.func,
onPaste: PropTypes.func, onPaste: PropTypes.func,
onMediaDescriptionConfirm: 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 = () => { handleFocus = () => {
if (this.composeForm) { if (this.composeForm) {
this.composeForm.scrollIntoView(); this.composeForm.scrollIntoView();

View file

@ -9,10 +9,8 @@ import {
clearComposeSuggestions, clearComposeSuggestions,
fetchComposeSuggestions, fetchComposeSuggestions,
insertEmojiCompose, insertEmojiCompose,
mountCompose,
selectComposeSuggestion, selectComposeSuggestion,
submitCompose, submitCompose,
unmountCompose,
uploadCompose, uploadCompose,
} from 'flavours/glitch/actions/compose'; } from 'flavours/glitch/actions/compose';
import { import {
@ -114,14 +112,6 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
dispatch(changeComposeVisibility(value)); dispatch(changeComposeVisibility(value));
}, },
onMount() {
dispatch(mountCompose());
},
onUnmount() {
dispatch(unmountCompose());
},
onMediaDescriptionConfirm(routerHistory) { onMediaDescriptionConfirm(routerHistory) {
dispatch(openModal('CONFIRM', { dispatch(openModal('CONFIRM', {
message: intl.formatMessage(messages.missingDescriptionMessage), message: intl.formatMessage(messages.missingDescriptionMessage),

View file

@ -4,6 +4,7 @@ import NavigationContainer from './containers/navigation_container';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { mountCompose, unmountCompose } from 'flavours/glitch/actions/compose';
import { injectIntl, defineMessages } from 'react-intl'; import { injectIntl, defineMessages } from 'react-intl';
import classNames from 'classnames'; import classNames from 'classnames';
import SearchContainer from './containers/search_container'; import SearchContainer from './containers/search_container';
@ -27,6 +28,14 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onClickElefriend () { onClickElefriend () {
dispatch(cycleElefriendCompose()); dispatch(cycleElefriendCompose());
}, },
onMount () {
dispatch(mountCompose());
},
onUnmount () {
dispatch(unmountCompose());
},
}); });
export default @connect(mapStateToProps, mapDispatchToProps) export default @connect(mapStateToProps, mapDispatchToProps)
@ -38,9 +47,27 @@ class Compose extends React.PureComponent {
isSearchPage: PropTypes.bool, isSearchPage: PropTypes.bool,
elefriend: PropTypes.number, elefriend: PropTypes.number,
onClickElefriend: PropTypes.func, onClickElefriend: PropTypes.func,
onMount: PropTypes.func,
onUnmount: PropTypes.func,
intl: PropTypes.object.isRequired, 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 () { render () {
const { const {
elefriend, elefriend,