2017-01-16 21:27:58 +09:00
|
|
|
import { connect } from 'react-redux';
|
2017-04-22 03:05:35 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2017-01-16 21:27:58 +09:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import LoadingIndicator from '../../components/loading_indicator';
|
|
|
|
import { fetchFavouritedStatuses, expandFavouritedStatuses } from '../../actions/favourites';
|
|
|
|
import Column from '../ui/components/column';
|
|
|
|
import StatusList from '../../components/status_list';
|
2017-01-30 23:22:04 +09:00
|
|
|
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
|
2017-01-16 21:27:58 +09:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
heading: { id: 'column.favourites', defaultMessage: 'Favourites' }
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
statusIds: state.getIn(['status_lists', 'favourites', 'items']),
|
|
|
|
loaded: state.getIn(['status_lists', 'favourites', 'loaded']),
|
|
|
|
me: state.getIn(['meta', 'me'])
|
|
|
|
});
|
|
|
|
|
2017-04-22 03:05:35 +09:00
|
|
|
class Favourites extends React.PureComponent {
|
2017-01-16 21:27:58 +09:00
|
|
|
|
2017-04-22 03:05:35 +09:00
|
|
|
constructor (props, context) {
|
|
|
|
super(props, context);
|
|
|
|
this.handleScrollToBottom = this.handleScrollToBottom.bind(this);
|
|
|
|
}
|
2017-01-16 21:27:58 +09:00
|
|
|
|
|
|
|
componentWillMount () {
|
|
|
|
this.props.dispatch(fetchFavouritedStatuses());
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-01-16 21:27:58 +09:00
|
|
|
|
|
|
|
handleScrollToBottom () {
|
|
|
|
this.props.dispatch(expandFavouritedStatuses());
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-01-16 21:27:58 +09:00
|
|
|
|
|
|
|
render () {
|
|
|
|
const { statusIds, loaded, intl, me } = this.props;
|
|
|
|
|
|
|
|
if (!loaded) {
|
|
|
|
return (
|
|
|
|
<Column>
|
|
|
|
<LoadingIndicator />
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Column icon='star' heading={intl.formatMessage(messages.heading)}>
|
2017-01-30 23:22:04 +09:00
|
|
|
<ColumnBackButtonSlim />
|
2017-01-16 21:27:58 +09:00
|
|
|
<StatusList statusIds={statusIds} me={me} onScrollToBottom={this.handleScrollToBottom} />
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
Favourites.propTypes = {
|
|
|
|
params: PropTypes.object.isRequired,
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
statusIds: ImmutablePropTypes.list.isRequired,
|
|
|
|
loaded: PropTypes.bool,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
me: PropTypes.number.isRequired
|
|
|
|
};
|
2017-01-16 21:27:58 +09:00
|
|
|
|
|
|
|
export default connect(mapStateToProps)(injectIntl(Favourites));
|