2019-05-26 00:55:37 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { fetchFollowRequests } from 'mastodon/actions/accounts';
|
|
|
|
import { connect } from 'react-redux';
|
2022-10-09 13:55:32 +00:00
|
|
|
import ColumnLink from 'mastodon/features/ui/components/column_link';
|
2019-05-26 00:55:37 +00:00
|
|
|
import IconWithBadge from 'mastodon/components/icon_with_badge';
|
|
|
|
import { List as ImmutableList } from 'immutable';
|
2022-10-09 13:55:32 +00:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
text: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
|
|
|
|
});
|
2019-05-26 00:55:37 +00:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
count: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size,
|
|
|
|
});
|
|
|
|
|
2022-10-09 13:55:32 +00:00
|
|
|
class FollowRequestsColumnLink extends React.Component {
|
2019-05-26 00:55:37 +00:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
count: PropTypes.number.isRequired,
|
2022-10-09 13:55:32 +00:00
|
|
|
intl: PropTypes.object.isRequired,
|
2019-05-26 00:55:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
componentDidMount () {
|
2019-12-01 16:25:29 +00:00
|
|
|
const { dispatch } = this.props;
|
2019-05-26 00:55:37 +00:00
|
|
|
|
2019-12-01 16:25:29 +00:00
|
|
|
dispatch(fetchFollowRequests());
|
2019-05-26 00:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2022-10-09 13:55:32 +00:00
|
|
|
const { count, intl } = this.props;
|
2019-05-26 00:55:37 +00:00
|
|
|
|
2019-12-01 16:25:29 +00:00
|
|
|
if (count === 0) {
|
2019-05-26 00:55:37 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-10-09 13:55:32 +00:00
|
|
|
return (
|
|
|
|
<ColumnLink
|
|
|
|
transparent
|
|
|
|
to='/follow_requests'
|
|
|
|
icon={<IconWithBadge className='column-link__icon' id='user-plus' count={count} />}
|
|
|
|
text={intl.formatMessage(messages.text)}
|
|
|
|
/>
|
|
|
|
);
|
2019-05-26 00:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-03-24 02:17:53 +00:00
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps)(FollowRequestsColumnLink));
|