mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-25 01:24:02 -05:00
f5bf5ebb82
* Replace browserify with webpack * Add react-intl-translations-manager * Do not minify in development, add offline-plugin for ServiceWorker background cache updates * Adjust tests and dependencies * Fix production deployments * Fix tests * More optimizations * Improve travis cache for npm stuff * Re-run travis * Add back support for custom.scss as before * Remove offline-plugin and babili * Fix issue with Immutable.List().unshift(...values) not working as expected * Make travis load schema instead of running all migrations in sequence * Fix missing React import in WarningContainer. Optimize rendering performance by using ImmutablePureComponent instead of React.PureComponent. ImmutablePureComponent uses Immutable.is() to compare props. Replace dynamic callback bindings in <UI /> * Add react definitions to places that use JSX * Add Procfile.dev for running rails, webpack and streaming API at the same time
68 lines
2.0 KiB
JavaScript
68 lines
2.0 KiB
JavaScript
import React from 'react';
|
|
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';
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
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 ImmutablePureComponent {
|
|
|
|
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 {...this.props} scrollKey='favourited_statuses' onScrollToBottom={this.handleScrollToBottom} />
|
|
</Column>
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
Favourites.propTypes = {
|
|
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));
|