mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-16 13:14:17 -05:00
1948f9e767
* Remove deprecated features at React v15.5
- [x] React.PropTypes
- [x] react-addons-pure-render-mixin
- [x] react-addons-test-utils
* Uncommented out & Add browserify_rails options
* re-add react-addons-shallow
* Fix syntax error from resolve conflicts
* follow up 59a77923b3
67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import PropTypes from 'prop-types';
|
|
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';
|
|
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
|
|
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'])
|
|
});
|
|
|
|
class Favourites extends React.PureComponent {
|
|
|
|
constructor (props, context) {
|
|
super(props, context);
|
|
this.handleScrollToBottom = this.handleScrollToBottom.bind(this);
|
|
}
|
|
|
|
componentWillMount () {
|
|
this.props.dispatch(fetchFavouritedStatuses());
|
|
}
|
|
|
|
handleScrollToBottom () {
|
|
this.props.dispatch(expandFavouritedStatuses());
|
|
}
|
|
|
|
render () {
|
|
const { statusIds, loaded, intl, me } = this.props;
|
|
|
|
if (!loaded) {
|
|
return (
|
|
<Column>
|
|
<LoadingIndicator />
|
|
</Column>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Column icon='star' heading={intl.formatMessage(messages.heading)}>
|
|
<ColumnBackButtonSlim />
|
|
<StatusList statusIds={statusIds} me={me} onScrollToBottom={this.handleScrollToBottom} />
|
|
</Column>
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
};
|
|
|
|
export default connect(mapStateToProps)(injectIntl(Favourites));
|