2020-03-27 13:59:38 -07: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 StatusList from '../../components/status_list';
|
|
|
|
import { injectIntl, FormattedMessage } from 'react-intl';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2020-05-28 15:52:07 -07:00
|
|
|
import MissingIndicator from 'soapbox/components/missing_indicator';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2021-07-02 13:06:27 -07:00
|
|
|
const mapStateToProps = (state, { params }) => {
|
|
|
|
const username = params.username || '';
|
2020-04-17 15:14:04 -07:00
|
|
|
const me = state.get('me');
|
2021-09-10 09:44:18 -07:00
|
|
|
const meUsername = state.getIn(['accounts', me, 'username'], '');
|
2020-03-27 13:59:38 -07:00
|
|
|
return {
|
|
|
|
isMyAccount: (username.toLowerCase() === meUsername.toLowerCase()),
|
|
|
|
statusIds: state.getIn(['status_lists', 'pins', 'items']),
|
|
|
|
hasMore: !!state.getIn(['status_lists', 'pins', 'next']),
|
|
|
|
};
|
2021-08-03 12:22:51 -07:00
|
|
|
};
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
|
|
|
@injectIntl
|
|
|
|
class PinnedStatuses extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
2021-07-08 14:12:04 -07:00
|
|
|
statusIds: ImmutablePropTypes.orderedSet.isRequired,
|
2020-03-27 13:59:38 -07:00
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
hasMore: PropTypes.bool.isRequired,
|
|
|
|
isMyAccount: PropTypes.bool.isRequired,
|
|
|
|
};
|
|
|
|
|
2020-06-17 18:42:30 -07:00
|
|
|
componentDidMount() {
|
2020-03-27 13:59:38 -07:00
|
|
|
this.props.dispatch(fetchPinnedStatuses());
|
|
|
|
}
|
|
|
|
|
2020-04-14 14:47:35 -07:00
|
|
|
render() {
|
2020-04-14 13:45:38 -07:00
|
|
|
const { statusIds, hasMore, isMyAccount } = this.props;
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
if (!isMyAccount) {
|
|
|
|
return (
|
|
|
|
<Column>
|
|
|
|
<MissingIndicator />
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Column>
|
|
|
|
<StatusList
|
|
|
|
statusIds={statusIds}
|
|
|
|
scrollKey='pinned_statuses'
|
|
|
|
hasMore={hasMore}
|
2020-04-14 11:44:40 -07:00
|
|
|
emptyMessage={<FormattedMessage id='pinned_statuses.none' defaultMessage='No pins to show.' />}
|
2020-03-27 13:59:38 -07:00
|
|
|
/>
|
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|