// Components.
import ComposerOptions from '../../composer/options';
import ComposerPublisher from '../../composer/publisher';
-import ComposerReply from '../../composer/reply';
import ComposerSpoiler from '../../composer/spoiler';
import ComposerTextarea from '../../composer/textarea';
import ComposerUploadForm from '../../composer/upload_form';
import ComposerPollForm from '../../composer/poll_form';
import WarningContainer from '../containers/warning_container';
+import ReplyIndicatorContainer from '../containers/reply_indicator_container';
// Utils.
import { countableText } from 'flavours/glitch/util/counter';
preselectDate: PropTypes.instanceOf(Date),
privacy: PropTypes.string,
progress: PropTypes.number,
- inReplyTo: ImmutablePropTypes.map,
resetFileKey: PropTypes.number,
sideArm: PropTypes.string,
sensitive: PropTypes.bool,
preselectOnReply: PropTypes.bool,
// Dispatch props.
- onCancelReply: PropTypes.func,
onChangeAdvancedOption: PropTypes.func,
onChangeDescription: PropTypes.func,
onChangeSensitivity: PropTypes.func,
layout,
media,
poll,
- onCancelReply,
onChangeAdvancedOption,
onChangeDescription,
onChangeSensitivity,
onUpload,
privacy,
progress,
- inReplyTo,
resetFileKey,
sensitive,
showSearch,
<div className='composer'>
<WarningContainer />
- {inReplyTo && (
- <ComposerReply
- status={inReplyTo}
- intl={intl}
- onCancel={onCancelReply}
- />
- )}
+ <ReplyIndicatorContainer />
<ComposerSpoiler
hidden={!spoiler}
import PropTypes from 'prop-types';
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
-import { defineMessages } from 'react-intl';
+import { defineMessages, injectIntl } from 'react-intl';
+import ImmutablePureComponent from 'react-immutable-pure-component';
// Components.
import AccountContainer from 'flavours/glitch/containers/account_container';
import AttachmentList from 'flavours/glitch/components/attachment_list';
// Utils.
-import { assignHandlers } from 'flavours/glitch/util/react_helpers';
import { isRtl } from 'flavours/glitch/util/rtl';
// Messages.
},
});
-// Handlers.
-const handlers = {
- // Handles a click on the "close" button.
- handleClick () {
+export default @injectIntl
+class ReplyIndicator extends ImmutablePureComponent {
+
+ static propTypes = {
+ status: ImmutablePropTypes.map.isRequired,
+ intl: PropTypes.object.isRequired,
+ onCancel: PropTypes.func,
+ };
+
+ handleClick = () => {
const { onCancel } = this.props;
if (onCancel) {
onCancel();
}
- },
-};
-
-// The component.
-export default class ComposerReply extends React.PureComponent {
-
- // Constructor.
- constructor (props) {
- super(props);
- assignHandlers(this, handlers);
}
// Rendering.
render () {
- const { handleClick } = this.handlers;
- const {
- status,
- intl,
- } = this.props;
+ const { status, intl } = this.props;
+
+ if (!status) {
+ return null;
+ }
const account = status.get('account');
const content = status.get('content');
<IconButton
className='cancel'
icon='times'
- onClick={handleClick}
+ onClick={this.handleClick}
title={intl.formatMessage(messages.cancel)}
inverted
/>
}
}
-
-ComposerReply.propTypes = {
- status: ImmutablePropTypes.map.isRequired,
- intl: PropTypes.object.isRequired,
- onCancel: PropTypes.func,
-};
import { connect } from 'react-redux';
import ComposeForm from '../components/compose_form';
import {
- cancelReplyCompose,
changeCompose,
changeComposeAdvancedOption,
changeComposeSensitivity,
preselectDate: state.getIn(['compose', 'preselectDate']),
privacy: state.getIn(['compose', 'privacy']),
progress: state.getIn(['compose', 'progress']),
- inReplyTo: inReplyTo ? state.getIn(['statuses', inReplyTo]) : null,
- replyAccount: inReplyTo ? state.getIn(['statuses', inReplyTo, 'account']) : null,
- replyContent: inReplyTo ? state.getIn(['statuses', inReplyTo, 'contentHtml']) : null,
resetFileKey: state.getIn(['compose', 'resetFileKey']),
sideArm: sideArmPrivacy,
sensitive: state.getIn(['compose', 'sensitive']),
// Dispatch mapping.
const mapDispatchToProps = (dispatch, { intl }) => ({
- onCancelReply() {
- dispatch(cancelReplyCompose());
- },
onChangeAdvancedOption(option, value) {
dispatch(changeComposeAdvancedOption(option, value));
},
--- /dev/null
+import { connect } from 'react-redux';
+import { cancelReplyCompose } from 'flavours/glitch/actions/compose';
+import { makeGetStatus } from 'flavours/glitch/selectors';
+import ReplyIndicator from '../components/reply_indicator';
+
+function makeMapStateToProps (state) {
+ const inReplyTo = state.getIn(['compose', 'in_reply_to']);
+
+ return {
+ status: inReplyTo ? state.getIn(['statuses', inReplyTo]) : null,
+ };
+};
+
+const mapDispatchToProps = dispatch => ({
+
+ onCancel () {
+ dispatch(cancelReplyCompose());
+ },
+
+});
+
+export default connect(makeMapStateToProps, mapDispatchToProps)(ReplyIndicator);