2020-05-27 17:16:42 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2020-05-27 17:36:23 -07:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { connect } from 'react-redux';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2021-10-06 08:58:29 -07:00
|
|
|
import { getFeatures } from 'soapbox/utils/features';
|
2020-05-27 17:16:42 -07:00
|
|
|
|
2020-05-27 17:36:23 -07:00
|
|
|
const messages = defineMessages({
|
2020-06-06 12:06:45 -07:00
|
|
|
following: {
|
|
|
|
id: 'morefollows.following_label',
|
|
|
|
defaultMessage: '…and {count} more {count, plural, one {follow} other {follows}} on remote sites.',
|
2020-05-27 17:36:23 -07:00
|
|
|
},
|
2020-06-06 12:06:45 -07:00
|
|
|
followers: {
|
|
|
|
id: 'morefollows.followers_label',
|
|
|
|
defaultMessage: '…and {count} more {count, plural, one {follower} other {followers}} on remote sites.',
|
2020-05-27 17:36:23 -07:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2021-10-06 08:58:29 -07:00
|
|
|
const mapStateToProps = state => {
|
|
|
|
const instance = state.get('instance');
|
|
|
|
|
|
|
|
return {
|
|
|
|
features: getFeatures(instance),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
|
|
|
@injectIntl
|
2020-05-27 17:36:23 -07:00
|
|
|
class MoreFollows extends React.PureComponent {
|
2020-05-27 17:16:42 -07:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
visible: PropTypes.bool,
|
2020-05-27 17:36:23 -07:00
|
|
|
count: PropTypes.number,
|
|
|
|
type: PropTypes.string,
|
|
|
|
intl: PropTypes.object.isRequired,
|
2021-10-06 08:58:29 -07:00
|
|
|
features: PropTypes.object.isRequired,
|
2020-05-27 17:16:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
visible: true,
|
|
|
|
}
|
|
|
|
|
2020-05-27 17:36:23 -07:00
|
|
|
getMessage = () => {
|
|
|
|
const { type, count, intl } = this.props;
|
2020-06-06 12:06:45 -07:00
|
|
|
return intl.formatMessage(messages[type], { count });
|
2020-05-27 17:36:23 -07:00
|
|
|
}
|
2020-05-27 17:16:42 -07:00
|
|
|
|
2020-05-27 17:36:23 -07:00
|
|
|
render() {
|
2021-10-06 08:58:29 -07:00
|
|
|
const { features } = this.props;
|
|
|
|
|
|
|
|
// If the instance isn't federating, there are no remote followers
|
|
|
|
if (!features.federating) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-05-27 17:36:23 -07:00
|
|
|
return (
|
|
|
|
<div className='morefollows-indicator'>
|
|
|
|
<div>
|
|
|
|
<div className='morefollows-indicator__label' style={{ visibility: this.props.visible ? 'visible' : 'hidden' }}>
|
|
|
|
{this.getMessage()}
|
2020-05-27 17:16:42 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-05-27 17:36:23 -07:00
|
|
|
</div>
|
|
|
|
);
|
2020-05-27 17:16:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|