* Add follow_request notification type The notification type already existed in the backend but was never pushed to the front-end. This also means translation strings were also available for the backend, from the notification mailer. Unlike other notification types, these are off by default, to match what I remember of Gargron's view on the topic: that follow requests should not clutter notifications and should instead be reviewed at the user's own leisure in the dedicated column. Since follow requests have their own column, I've deemed it unnecessary to add a specific tab for them in the notification quick filter. * Show follow request link in single-column if there are pending requests, even if account isn't locked * Push follow requests from notifications to the follow_requests list * Offer to accept or reject follow request from the notification * Redesign follow request notification
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { fetchFollowRequests } from 'mastodon/actions/accounts';
|
|
import { connect } from 'react-redux';
|
|
import { NavLink, withRouter } from 'react-router-dom';
|
|
import IconWithBadge from 'mastodon/components/icon_with_badge';
|
|
import { List as ImmutableList } from 'immutable';
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
const mapStateToProps = state => ({
|
|
count: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size,
|
|
});
|
|
|
|
export default @withRouter
|
|
@connect(mapStateToProps)
|
|
class FollowRequestsNavLink extends React.Component {
|
|
|
|
static propTypes = {
|
|
dispatch: PropTypes.func.isRequired,
|
|
count: PropTypes.number.isRequired,
|
|
};
|
|
|
|
componentDidMount () {
|
|
const { dispatch } = this.props;
|
|
|
|
dispatch(fetchFollowRequests());
|
|
}
|
|
|
|
render () {
|
|
const { count } = this.props;
|
|
|
|
if (count === 0) {
|
|
return null;
|
|
}
|
|
|
|
return <NavLink className='column-link column-link--transparent' to='/follow_requests'><IconWithBadge className='column-link__icon' id='user-plus' count={count} /><FormattedMessage id='navigation_bar.follow_requests' defaultMessage='Follow requests' /></NavLink>;
|
|
}
|
|
|
|
}
|