import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import { List as ImmutableList } from 'immutable' import { injectIntl, defineMessages } from 'react-intl' import { MODAL_COMPOSE } from '../constants' import { expandAccountFeaturedTimeline, expandAccountTimeline } from '../actions/timelines' import { openModal } from '../actions/modal' import StatusList from '../components/status_list' import Text from '../components/text' import Button from '../components/button' class AccountTimeline extends ImmutablePureComponent { componentWillMount() { const { accountId, commentsOnly, isDeckConnected } = this.props if (accountId && accountId !== -1) { if (!commentsOnly && !isDeckConnected) { this.props.dispatch(expandAccountFeaturedTimeline(accountId)) } this.props.dispatch(expandAccountTimeline(accountId, { commentsOnly })) } } componentWillReceiveProps(nextProps) { if (nextProps.accountId && nextProps.accountId !== -1 && (nextProps.accountId !== this.props.accountId && nextProps.accountId) || nextProps.commentsOnly !== this.props.commentsOnly) { if (!nextProps.commentsOnly && !nextProps.isDeckConnected) { this.props.dispatch(expandAccountFeaturedTimeline(nextProps.accountId)) } this.props.dispatch(expandAccountTimeline(nextProps.accountId, { commentsOnly: nextProps.commentsOnly })) } } handleLoadMore = (maxId) => { if (this.props.accountId && this.props.accountId !== -1) { this.props.dispatch(expandAccountTimeline(this.props.accountId, { maxId, commentsOnly: this.props.commentsOnly })) } } handleOnOpenComposeModal = () => { this.props.dispatch(openModal(MODAL_COMPOSE)) } render() { const { statusIds, featuredStatusIds, isLoading, hasMore, intl, isMe, } = this.props const emptyMessage = (