2018-07-11 05:29:10 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { makeSelectNsfwCountForChannel, makeSelectNsfwCountFromUris, parseURI } from 'lbry-redux';
|
2019-08-02 08:28:14 +02:00
|
|
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
2018-07-11 05:29:10 +02:00
|
|
|
import HiddenNsfwClaims from './view';
|
|
|
|
|
|
|
|
const select = (state, props) => {
|
|
|
|
const { uri, uris } = props;
|
|
|
|
|
|
|
|
let numberOfNsfwClaims;
|
|
|
|
if (uri) {
|
|
|
|
const { isChannel } = parseURI(uri);
|
|
|
|
numberOfNsfwClaims = isChannel
|
|
|
|
? makeSelectNsfwCountForChannel(uri)(state)
|
|
|
|
: makeSelectNsfwCountFromUris([uri])(state);
|
|
|
|
} else if (uris) {
|
|
|
|
numberOfNsfwClaims = makeSelectNsfwCountFromUris(uris)(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
numberOfNsfwClaims,
|
2019-08-02 08:28:14 +02:00
|
|
|
obscureNsfw: !selectShowMatureContent(state),
|
2018-07-11 05:29:10 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const perform = () => ({});
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
select,
|
|
|
|
perform
|
|
|
|
)(HiddenNsfwClaims);
|