2017-09-07 07:58:11 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import { fetchPinnedStatuses } from '../../actions/pin_statuses';
|
|
|
|
import Column from '../ui/components/column';
|
|
|
|
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
|
|
|
|
import StatusList from '../../components/status_list';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
heading: { id: 'column.pins', defaultMessage: 'Pinned toot' },
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
statusIds: state.getIn(['status_lists', 'pins', 'items']),
|
|
|
|
hasMore: !!state.getIn(['status_lists', 'pins', 'next']),
|
|
|
|
});
|
|
|
|
|
2018-09-14 15:59:48 +00:00
|
|
|
export default @connect(mapStateToProps)
|
2017-09-07 07:58:11 +00:00
|
|
|
@injectIntl
|
2018-09-14 15:59:48 +00:00
|
|
|
class PinnedStatuses extends ImmutablePureComponent {
|
2017-09-07 07:58:11 +00:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
2018-07-29 14:52:06 +00:00
|
|
|
shouldUpdateScroll: PropTypes.func,
|
2017-09-07 07:58:11 +00:00
|
|
|
statusIds: ImmutablePropTypes.list.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
hasMore: PropTypes.bool.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
componentWillMount () {
|
|
|
|
this.props.dispatch(fetchPinnedStatuses());
|
|
|
|
}
|
|
|
|
|
|
|
|
handleHeaderClick = () => {
|
|
|
|
this.column.scrollTop();
|
|
|
|
}
|
|
|
|
|
|
|
|
setRef = c => {
|
|
|
|
this.column = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2018-07-29 14:52:06 +00:00
|
|
|
const { intl, shouldUpdateScroll, statusIds, hasMore } = this.props;
|
2017-09-07 07:58:11 +00:00
|
|
|
|
|
|
|
return (
|
2018-09-27 15:08:56 +00:00
|
|
|
<Column icon='thumbtack' heading={intl.formatMessage(messages.heading)} ref={this.setRef}>
|
2017-09-07 07:58:11 +00:00
|
|
|
<ColumnBackButtonSlim />
|
|
|
|
<StatusList
|
|
|
|
statusIds={statusIds}
|
|
|
|
scrollKey='pinned_statuses'
|
|
|
|
hasMore={hasMore}
|
2018-07-29 14:52:06 +00:00
|
|
|
shouldUpdateScroll={shouldUpdateScroll}
|
2017-09-07 07:58:11 +00:00
|
|
|
/>
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|