lbry-desktop/ui/component/hiddenNsfwClaims/index.js
2019-11-25 15:13:19 -05:00

30 lines
824 B
JavaScript

import { connect } from 'react-redux';
import { makeSelectNsfwCountFromUris, makeSelectOmittedCountForChannel, parseURI } from 'lbry-redux';
import { selectShowMatureContent } from 'redux/selectors/settings';
import HiddenNsfwClaims from './view';
const select = (state, props) => {
const { uri, uris } = props;
let numberOfHiddenClaims;
if (uri) {
const { isChannel } = parseURI(uri);
numberOfHiddenClaims = isChannel
? makeSelectOmittedCountForChannel(uri)(state)
: makeSelectNsfwCountFromUris([uri])(state);
} else if (uris) {
numberOfHiddenClaims = makeSelectNsfwCountFromUris(uris)(state);
}
return {
numberOfHiddenClaims,
obscureNsfw: !selectShowMatureContent(state),
};
};
const perform = () => ({});
export default connect(
select,
perform
)(HiddenNsfwClaims);