You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
6.2 KiB
200 lines
6.2 KiB
![]()
8 years ago
|
import React from 'react';
|
||
![]()
8 years ago
|
import { connect } from 'react-redux';
|
||
![]()
8 years ago
|
import PropTypes from 'prop-types';
|
||
![]()
8 years ago
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
|
import { fetchStatus } from '../../actions/statuses';
|
||
|
import Immutable from 'immutable';
|
||
|
import EmbeddedStatus from '../../components/status';
|
||
![]()
8 years ago
|
import MissingIndicator from '../../components/missing_indicator';
|
||
![]()
8 years ago
|
import DetailedStatus from './components/detailed_status';
|
||
|
import ActionBar from './components/action_bar';
|
||
|
import Column from '../ui/components/column';
|
||
|
import {
|
||
|
favourite,
|
||
|
unfavourite,
|
||
|
reblog,
|
||
|
unreblog
|
||
|
} from '../../actions/interactions';
|
||
![]()
8 years ago
|
import {
|
||
|
replyCompose,
|
||
|
mentionCompose
|
||
![]()
8 years ago
|
} from '../../actions/compose';
|
||
|
import { deleteStatus } from '../../actions/statuses';
|
||
![]()
8 years ago
|
import { initReport } from '../../actions/reports';
|
||
![]()
8 years ago
|
import {
|
||
![]()
8 years ago
|
makeGetStatus,
|
||
![]()
8 years ago
|
getStatusAncestors,
|
||
|
getStatusDescendants
|
||
![]()
8 years ago
|
} from '../../selectors';
|
||
|
import { ScrollContainer } from 'react-router-scroll';
|
||
|
import ColumnBackButton from '../../components/column_back_button';
|
||
|
import StatusContainer from '../../containers/status_container';
|
||
![]()
8 years ago
|
import { openModal } from '../../actions/modal';
|
||
![]()
8 years ago
|
import { isMobile } from '../../is_mobile'
|
||
![]()
8 years ago
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||
![]()
8 years ago
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||
![]()
8 years ago
|
|
||
|
const messages = defineMessages({
|
||
|
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||
|
deleteMessage: { id: 'confirmations.delete.message', defaultMessage: 'Are you sure you want to delete this status?' }
|
||
|
});
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
const makeMapStateToProps = () => {
|
||
|
const getStatus = makeGetStatus();
|
||
|
|
||
|
const mapStateToProps = (state, props) => ({
|
||
|
status: getStatus(state, Number(props.params.statusId)),
|
||
|
ancestorsIds: state.getIn(['timelines', 'ancestors', Number(props.params.statusId)]),
|
||
|
descendantsIds: state.getIn(['timelines', 'descendants', Number(props.params.statusId)]),
|
||
![]()
8 years ago
|
me: state.getIn(['meta', 'me']),
|
||
![]()
8 years ago
|
boostModal: state.getIn(['meta', 'boost_modal']),
|
||
|
autoPlayGif: state.getIn(['meta', 'auto_play_gif'])
|
||
![]()
8 years ago
|
});
|
||
|
|
||
|
return mapStateToProps;
|
||
|
};
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
class Status extends ImmutablePureComponent {
|
||
![]()
8 years ago
|
|
||
|
constructor (props, context) {
|
||
|
super(props, context);
|
||
|
this.handleFavouriteClick = this.handleFavouriteClick.bind(this);
|
||
|
this.handleReplyClick = this.handleReplyClick.bind(this);
|
||
|
this.handleModalReblog = this.handleModalReblog.bind(this);
|
||
|
this.handleReblogClick = this.handleReblogClick.bind(this);
|
||
|
this.handleDeleteClick = this.handleDeleteClick.bind(this);
|
||
|
this.handleMentionClick = this.handleMentionClick.bind(this);
|
||
|
this.handleOpenMedia = this.handleOpenMedia.bind(this);
|
||
|
this.handleOpenVideo = this.handleOpenVideo.bind(this);
|
||
|
this.handleReport = this.handleReport.bind(this);
|
||
|
}
|
||
![]()
8 years ago
|
|
||
|
componentWillMount () {
|
||
![]()
8 years ago
|
this.props.dispatch(fetchStatus(Number(this.props.params.statusId)));
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
|
componentWillReceiveProps (nextProps) {
|
||
|
if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
|
||
![]()
8 years ago
|
this.props.dispatch(fetchStatus(Number(nextProps.params.statusId)));
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
handleFavouriteClick (status) {
|
||
![]()
8 years ago
|
if (status.get('favourited')) {
|
||
|
this.props.dispatch(unfavourite(status));
|
||
|
} else {
|
||
|
this.props.dispatch(favourite(status));
|
||
|
}
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
|
handleReplyClick (status) {
|
||
![]()
8 years ago
|
this.props.dispatch(replyCompose(status, this.context.router));
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
handleModalReblog (status) {
|
||
|
this.props.dispatch(reblog(status));
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
handleReblogClick (status, e) {
|
||
![]()
8 years ago
|
if (status.get('reblogged')) {
|
||
|
this.props.dispatch(unreblog(status));
|
||
|
} else {
|
||
![]()
8 years ago
|
if (e.shiftKey || !this.props.boostModal) {
|
||
![]()
8 years ago
|
this.handleModalReblog(status);
|
||
|
} else {
|
||
|
this.props.dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog }));
|
||
|
}
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
handleDeleteClick (status) {
|
||
![]()
8 years ago
|
const { dispatch, intl } = this.props;
|
||
|
|
||
|
dispatch(openModal('CONFIRM', {
|
||
|
message: intl.formatMessage(messages.deleteMessage),
|
||
|
confirm: intl.formatMessage(messages.deleteConfirm),
|
||
|
onConfirm: () => dispatch(deleteStatus(status.get('id')))
|
||
|
}));
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
handleMentionClick (account, router) {
|
||
|
this.props.dispatch(mentionCompose(account, router));
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
handleOpenMedia (media, index) {
|
||
![]()
8 years ago
|
this.props.dispatch(openModal('MEDIA', { media, index }));
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
handleOpenVideo (media, time) {
|
||
|
this.props.dispatch(openModal('VIDEO', { media, time }));
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
handleReport (status) {
|
||
|
this.props.dispatch(initReport(status.get('account'), status));
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
renderChildren (list) {
|
||
![]()
8 years ago
|
return list.map(id => <StatusContainer key={id} id={id} />);
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
|
render () {
|
||
![]()
8 years ago
|
let ancestors, descendants;
|
||
![]()
8 years ago
|
const { status, ancestorsIds, descendantsIds, me, autoPlayGif } = this.props;
|
||
![]()
8 years ago
|
|
||
|
if (status === null) {
|
||
![]()
8 years ago
|
return (
|
||
|
<Column>
|
||
![]()
8 years ago
|
<ColumnBackButton />
|
||
![]()
8 years ago
|
<MissingIndicator />
|
||
![]()
8 years ago
|
</Column>
|
||
|
);
|
||
![]()
8 years ago
|
}
|
||
|
|
||
![]()
8 years ago
|
const account = status.get('account');
|
||
|
|
||
![]()
8 years ago
|
if (ancestorsIds && ancestorsIds.size > 0) {
|
||
![]()
8 years ago
|
ancestors = <div>{this.renderChildren(ancestorsIds)}</div>;
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
if (descendantsIds && descendantsIds.size > 0) {
|
||
![]()
8 years ago
|
descendants = <div>{this.renderChildren(descendantsIds)}</div>;
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
return (
|
||
![]()
8 years ago
|
<Column>
|
||
![]()
8 years ago
|
<ColumnBackButton />
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
<ScrollContainer scrollKey='thread'>
|
||
![]()
8 years ago
|
<div className='scrollable detailed-status__wrapper'>
|
||
![]()
8 years ago
|
{ancestors}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
<DetailedStatus status={status} autoPlayGif={autoPlayGif} me={me} onOpenVideo={this.handleOpenVideo} onOpenMedia={this.handleOpenMedia} />
|
||
![]()
8 years ago
|
<ActionBar status={status} me={me} onReply={this.handleReplyClick} onFavourite={this.handleFavouriteClick} onReblog={this.handleReblogClick} onDelete={this.handleDeleteClick} onMention={this.handleMentionClick} onReport={this.handleReport} />
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
{descendants}
|
||
![]()
8 years ago
|
</div>
|
||
|
</ScrollContainer>
|
||
![]()
8 years ago
|
</Column>
|
||
![]()
8 years ago
|
);
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
}
|
||
|
|
||
|
Status.contextTypes = {
|
||
|
router: PropTypes.object
|
||
|
};
|
||
|
|
||
|
Status.propTypes = {
|
||
|
params: PropTypes.object.isRequired,
|
||
|
dispatch: PropTypes.func.isRequired,
|
||
|
status: ImmutablePropTypes.map,
|
||
|
ancestorsIds: ImmutablePropTypes.list,
|
||
|
descendantsIds: ImmutablePropTypes.list,
|
||
|
me: PropTypes.number,
|
||
|
boostModal: PropTypes.bool,
|
||
![]()
8 years ago
|
autoPlayGif: PropTypes.bool,
|
||
|
intl: PropTypes.object.isRequired
|
||
![]()
8 years ago
|
};
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
export default injectIntl(connect(makeMapStateToProps)(Status));
|