2019-08-07 06:02:36 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
import { fetchPinnedStatuses } from '../../actions/pin_statuses';
|
2020-01-29 21:53:33 +00:00
|
|
|
import { meUsername } from '../../initial_state';
|
2019-08-07 06:02:36 +01:00
|
|
|
import Column from '../../components/column';
|
|
|
|
import StatusList from '../../components/status_list/status_list';
|
|
|
|
import ColumnIndicator from '../../components/column_indicator/column_indicator';
|
|
|
|
|
|
|
|
const mapStateToProps = (state, { params: { username } }) => {
|
|
|
|
return {
|
|
|
|
isMyAccount: (username.toLowerCase() === meUsername.toLowerCase()),
|
|
|
|
statusIds: state.getIn(['status_lists', 'pins', 'items']),
|
|
|
|
hasMore: !!state.getIn(['status_lists', 'pins', 'next']),
|
|
|
|
};
|
|
|
|
};;
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
|
|
|
class PinnedStatuses extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
statusIds: ImmutablePropTypes.list.isRequired,
|
|
|
|
hasMore: PropTypes.bool.isRequired,
|
|
|
|
isMyAccount: PropTypes.bool.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
componentWillMount () {
|
|
|
|
this.props.dispatch(fetchPinnedStatuses());
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { statusIds, hasMore, isMyAccount } = this.props;
|
|
|
|
|
|
|
|
if (!isMyAccount) {
|
|
|
|
return (<ColumnIndicator type='missing' />);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Column>
|
|
|
|
<StatusList
|
|
|
|
statusIds={statusIds}
|
|
|
|
scrollKey='pinned_statuses'
|
|
|
|
hasMore={hasMore}
|
|
|
|
emptyMessage={<FormattedMessage id='pinned_statuses.none' defaultMessage='No pins to show.' />}
|
|
|
|
/>
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|