provide ad blacklisting

This commit is contained in:
zeppi 2021-01-30 22:47:06 -05:00 committed by jessopb
parent 64874c773b
commit 11931d4037
3 changed files with 14 additions and 3 deletions

View file

@ -61,7 +61,7 @@ export default function RecommendedContent(props: Props) {
injectedItem={
SHOW_ADS && IS_WEB ? (
SIMPLE_SITE ? (
<Ads small type={'google'} />
<Ads small type={'google'} uri={uri} />
) : (
!isAuthenticated && <Ads small type={'video'} />
)

View file

@ -1,8 +1,11 @@
import { connect } from 'react-redux';
import { selectTheme } from 'redux/selectors/settings';
import { makeSelectClaimForUri, makeSelectClaimIsNsfw } from 'lbry-redux';
import Ads from './view';
const select = state => ({
const select = (state, props) => ({
theme: selectTheme(state),
claim: makeSelectClaimForUri(props.uri)(state),
isMature: makeSelectClaimIsNsfw(props.uri)(state),
});
export default connect(select)(Ads);

View file

@ -7,6 +7,7 @@ import { withRouter } from 'react-router';
import I18nMessage from 'component/i18nMessage';
import Button from 'component/button';
import classnames from 'classnames';
import { ADS_CHANNEL_BLACKLIST } from 'homepages';
const ADS_URL = '//assets.revcontent.com/master/delivery.js';
const IS_MOBILE = typeof window.orientation !== 'undefined';
@ -25,6 +26,8 @@ type Props = {
type: string,
small: boolean,
theme: string,
claim: GenericClaim,
isMature: boolean,
};
function Ads(props: Props) {
@ -33,9 +36,14 @@ function Ads(props: Props) {
type = 'sidebar',
small,
theme,
claim,
isMature,
} = props;
let googleInit;
const channelId = claim && claim.signing_channel && claim.signing_channel.claim_id;
const isBlocked = isMature || (ADS_CHANNEL_BLACKLIST && ADS_CHANNEL_BLACKLIST.includes(channelId));
useEffect(() => {
if (SHOW_ADS && type === 'video') {
let script;
@ -162,7 +170,7 @@ function Ads(props: Props) {
</div>
);
if (!SHOW_ADS) {
if (!SHOW_ADS || (type === 'google' && isBlocked)) {
return false;
}
if (type === 'video') {