2016-10-09 20:18:54 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import {
|
|
|
|
fetchAccountTimeline,
|
|
|
|
expandAccountTimeline
|
|
|
|
} from '../../actions/accounts';
|
|
|
|
import StatusList from '../../components/status_list';
|
2016-10-24 17:11:02 +02:00
|
|
|
import LoadingIndicator from '../../components/loading_indicator';
|
2016-10-09 20:18:54 +02:00
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
2016-10-24 17:11:02 +02:00
|
|
|
statusIds: state.getIn(['timelines', 'accounts_timelines', Number(props.params.accountId)]),
|
2016-10-30 15:06:43 +01:00
|
|
|
me: state.getIn(['meta', 'me'])
|
2016-10-09 20:18:54 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
const AccountTimeline = React.createClass({
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
params: React.PropTypes.object.isRequired,
|
|
|
|
dispatch: React.PropTypes.func.isRequired,
|
2016-10-24 17:11:02 +02:00
|
|
|
statusIds: ImmutablePropTypes.list
|
2016-10-09 20:18:54 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
|
|
|
componentWillMount () {
|
|
|
|
this.props.dispatch(fetchAccountTimeline(Number(this.props.params.accountId)));
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
if (nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) {
|
|
|
|
this.props.dispatch(fetchAccountTimeline(Number(nextProps.params.accountId)));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
handleScrollToBottom () {
|
2016-10-17 01:23:41 +02:00
|
|
|
this.props.dispatch(expandAccountTimeline(Number(this.props.params.accountId)));
|
2016-10-09 20:18:54 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
render () {
|
2016-10-24 17:11:02 +02:00
|
|
|
const { statusIds, me } = this.props;
|
|
|
|
|
|
|
|
if (!statusIds) {
|
|
|
|
return <LoadingIndicator />;
|
|
|
|
}
|
2016-10-09 20:18:54 +02:00
|
|
|
|
2016-10-24 17:11:02 +02:00
|
|
|
return <StatusList statusIds={statusIds} me={me} onScrollToBottom={this.handleScrollToBottom} />
|
2016-10-09 20:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(AccountTimeline);
|