2017-05-03 10:04:16 +10:00
|
|
|
import React from 'react';
|
2017-01-16 23:27:58 +11:00
|
|
|
import { connect } from 'react-redux';
|
2017-04-22 04:05:35 +10:00
|
|
|
import PropTypes from 'prop-types';
|
2017-06-24 20:24:02 +10:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-01-16 23:27:58 +11:00
|
|
|
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-31 01:22:04 +11:00
|
|
|
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
|
2017-01-16 23:27:58 +11:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2017-05-03 10:04:16 +10:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2017-01-16 23:27:58 +11:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
2017-05-21 01:31:47 +10:00
|
|
|
heading: { id: 'column.favourites', defaultMessage: 'Favourites' },
|
2017-01-16 23:27:58 +11:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2017-06-24 20:24:02 +10:00
|
|
|
statusIds: state.getIn(['status_lists', 'favourites', 'items']),
|
2017-01-16 23:27:58 +11:00
|
|
|
loaded: state.getIn(['status_lists', 'favourites', 'loaded']),
|
2017-06-24 20:24:02 +10:00
|
|
|
me: state.getIn(['meta', 'me']),
|
2017-01-16 23:27:58 +11:00
|
|
|
});
|
|
|
|
|
2017-06-24 03:36:54 +10:00
|
|
|
@connect(mapStateToProps)
|
|
|
|
@injectIntl
|
|
|
|
export default class Favourites extends ImmutablePureComponent {
|
2017-01-16 23:27:58 +11:00
|
|
|
|
2017-05-12 22:44:10 +10:00
|
|
|
static propTypes = {
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
2017-06-24 20:24:02 +10:00
|
|
|
statusIds: ImmutablePropTypes.list.isRequired,
|
2017-05-12 22:44:10 +10:00
|
|
|
loaded: PropTypes.bool,
|
|
|
|
intl: PropTypes.object.isRequired,
|
2017-06-24 20:24:02 +10:00
|
|
|
me: PropTypes.number.isRequired,
|
2017-05-12 22:44:10 +10:00
|
|
|
};
|
2017-01-16 23:27:58 +11:00
|
|
|
|
|
|
|
componentWillMount () {
|
|
|
|
this.props.dispatch(fetchFavouritedStatuses());
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
2017-01-16 23:27:58 +11:00
|
|
|
|
2017-05-12 22:44:10 +10:00
|
|
|
handleScrollToBottom = () => {
|
2017-01-16 23:27:58 +11:00
|
|
|
this.props.dispatch(expandFavouritedStatuses());
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
2017-01-16 23:27:58 +11:00
|
|
|
|
|
|
|
render () {
|
2017-06-24 00:05:04 +10:00
|
|
|
const { loaded, intl } = this.props;
|
2017-01-16 23:27:58 +11:00
|
|
|
|
|
|
|
if (!loaded) {
|
|
|
|
return (
|
|
|
|
<Column>
|
|
|
|
<LoadingIndicator />
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Column icon='star' heading={intl.formatMessage(messages.heading)}>
|
2017-01-31 01:22:04 +11:00
|
|
|
<ColumnBackButtonSlim />
|
2017-05-03 10:04:16 +10:00
|
|
|
<StatusList {...this.props} scrollKey='favourited_statuses' onScrollToBottom={this.handleScrollToBottom} />
|
2017-01-16 23:27:58 +11:00
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|