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.
78 lines
2.6 KiB
78 lines
2.6 KiB
8 years ago
|
import React from 'react';
|
||
8 years ago
|
import { connect } from 'react-redux';
|
||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
8 years ago
|
import PropTypes from 'prop-types';
|
||
7 years ago
|
import { fetchAccount } from 'flavours/glitch/actions/accounts';
|
||
|
import { refreshAccountTimeline, expandAccountTimeline } from 'flavours/glitch/actions/timelines';
|
||
8 years ago
|
import StatusList from '../../components/status_list';
|
||
|
import LoadingIndicator from '../../components/loading_indicator';
|
||
8 years ago
|
import Column from '../ui/components/column';
|
||
|
import HeaderContainer from './containers/header_container';
|
||
|
import ColumnBackButton from '../../components/column_back_button';
|
||
8 years ago
|
import { List as ImmutableList } from 'immutable';
|
||
8 years ago
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||
8 years ago
|
|
||
|
const mapStateToProps = (state, props) => ({
|
||
7 years ago
|
statusIds: state.getIn(['timelines', `account:${props.params.accountId}`, 'items'], ImmutableList()),
|
||
|
isLoading: state.getIn(['timelines', `account:${props.params.accountId}`, 'isLoading']),
|
||
|
hasMore: !!state.getIn(['timelines', `account:${props.params.accountId}`, 'next']),
|
||
8 years ago
|
});
|
||
|
|
||
8 years ago
|
@connect(mapStateToProps)
|
||
|
export default class AccountTimeline extends ImmutablePureComponent {
|
||
8 years ago
|
|
||
8 years ago
|
static propTypes = {
|
||
|
params: PropTypes.object.isRequired,
|
||
|
dispatch: PropTypes.func.isRequired,
|
||
|
statusIds: ImmutablePropTypes.list,
|
||
|
isLoading: PropTypes.bool,
|
||
|
hasMore: PropTypes.bool,
|
||
|
};
|
||
8 years ago
|
|
||
|
componentWillMount () {
|
||
7 years ago
|
this.props.dispatch(fetchAccount(this.props.params.accountId));
|
||
|
this.props.dispatch(refreshAccountTimeline(this.props.params.accountId));
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
8 years ago
|
componentWillReceiveProps (nextProps) {
|
||
8 years ago
|
if (nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) {
|
||
7 years ago
|
this.props.dispatch(fetchAccount(nextProps.params.accountId));
|
||
|
this.props.dispatch(refreshAccountTimeline(nextProps.params.accountId));
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
8 years ago
|
handleScrollToBottom = () => {
|
||
8 years ago
|
if (!this.props.isLoading && this.props.hasMore) {
|
||
7 years ago
|
this.props.dispatch(expandAccountTimeline(this.props.params.accountId));
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
|
render () {
|
||
7 years ago
|
const { statusIds, isLoading, hasMore } = this.props;
|
||
8 years ago
|
|
||
8 years ago
|
if (!statusIds && isLoading) {
|
||
8 years ago
|
return (
|
||
|
<Column>
|
||
|
<LoadingIndicator />
|
||
|
</Column>
|
||
|
);
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
8 years ago
|
return (
|
||
7 years ago
|
<Column name='account'>
|
||
8 years ago
|
<ColumnBackButton />
|
||
|
|
||
|
<StatusList
|
||
|
prepend={<HeaderContainer accountId={this.props.params.accountId} />}
|
||
8 years ago
|
scrollKey='account_timeline'
|
||
8 years ago
|
statusIds={statusIds}
|
||
|
isLoading={isLoading}
|
||
8 years ago
|
hasMore={hasMore}
|
||
8 years ago
|
onScrollToBottom={this.handleScrollToBottom}
|
||
|
/>
|
||
|
</Column>
|
||
|
);
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
}
|