Code cleanup; no functional change
This commit is contained in:
parent
b0b0cd825b
commit
f979f9b575
1 changed files with 20 additions and 29 deletions
|
@ -7,15 +7,21 @@ import I18nMessage from 'component/i18nMessage';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
const ADS_URL =
|
// prettier-ignore
|
||||||
'https://cdn.vidcrunch.com/integrations/618bb4d28aac298191eec411/Lbry_Odysee.com_Responsive_Floating_DFP_Rev70_1011.js';
|
const AD_CONFIGS = Object.freeze({
|
||||||
const ADS_TAG = 'vidcrunchJS537102317';
|
DEFAULT: {
|
||||||
const MOBILE_ADS_URL =
|
url: 'https://cdn.vidcrunch.com/integrations/618bb4d28aac298191eec411/Lbry_Odysee.com_Responsive_Floating_DFP_Rev70_1011.js',
|
||||||
'https://cdn.vidcrunch.com/integrations/618bb4d28aac298191eec411/Lbry_Odysee.com_Mobile_Floating_DFP_Rev70_1611.js';
|
tag: 'vidcrunchJS537102317',
|
||||||
const MOBILE_ADS_TAG = 'vidcrunchJS199212779';
|
},
|
||||||
const EU_AD_URL =
|
MOBILE: {
|
||||||
'https://tg1.vidcrunch.com/api/adserver/spt?AV_TAGID=61dff05c599f1e20b01085d4&AV_PUBLISHERID=6182c8993c8ae776bd5635e9';
|
url: 'https://cdn.vidcrunch.com/integrations/618bb4d28aac298191eec411/Lbry_Odysee.com_Mobile_Floating_DFP_Rev70_1611.js',
|
||||||
const EU_AD_TAG = 'AV61dff05c599f1e20b01085d4';
|
tag: 'vidcrunchJS199212779',
|
||||||
|
},
|
||||||
|
EU: {
|
||||||
|
url: 'https://tg1.vidcrunch.com/api/adserver/spt?AV_TAGID=61dff05c599f1e20b01085d4&AV_PUBLISHERID=6182c8993c8ae776bd5635e9',
|
||||||
|
tag: 'AV61dff05c599f1e20b01085d4',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const IS_IOS =
|
const IS_IOS =
|
||||||
(/iPad|iPhone|iPod/.test(navigator.platform) ||
|
(/iPad|iPhone|iPod/.test(navigator.platform) ||
|
||||||
|
@ -57,23 +63,8 @@ function Ads(props: Props) {
|
||||||
const mobileAds = IS_ANDROID || IS_IOS;
|
const mobileAds = IS_ANDROID || IS_IOS;
|
||||||
|
|
||||||
// this is populated from app based on location
|
// this is populated from app based on location
|
||||||
let isInEu = localStorage.getItem('gdprRequired');
|
const isInEu = localStorage.getItem('gdprRequired') === 'true';
|
||||||
// cant store booleans so we store it as a string
|
const adConfig = isInEu ? AD_CONFIGS.EU : mobileAds ? AD_CONFIGS.MOBILE : AD_CONFIGS.DEFAULT;
|
||||||
isInEu = isInEu === 'true';
|
|
||||||
|
|
||||||
// load ad and tags here
|
|
||||||
let scriptUrlToUse;
|
|
||||||
let tagNameToUse;
|
|
||||||
if (isInEu) {
|
|
||||||
tagNameToUse = EU_AD_TAG;
|
|
||||||
scriptUrlToUse = EU_AD_URL;
|
|
||||||
} else if (mobileAds) {
|
|
||||||
tagNameToUse = MOBILE_ADS_TAG;
|
|
||||||
scriptUrlToUse = MOBILE_ADS_URL;
|
|
||||||
} else {
|
|
||||||
tagNameToUse = ADS_TAG;
|
|
||||||
scriptUrlToUse = ADS_URL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add script to DOM
|
// add script to DOM
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -83,7 +74,7 @@ function Ads(props: Props) {
|
||||||
let script;
|
let script;
|
||||||
try {
|
try {
|
||||||
script = document.createElement('script');
|
script = document.createElement('script');
|
||||||
script.src = scriptUrlToUse;
|
script.src = adConfig.url;
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
document.head.appendChild(script);
|
document.head.appendChild(script);
|
||||||
|
|
||||||
|
@ -129,7 +120,7 @@ function Ads(props: Props) {
|
||||||
const videoAd = (
|
const videoAd = (
|
||||||
<div className="ads__claim-item">
|
<div className="ads__claim-item">
|
||||||
<div className="ad__container">
|
<div className="ad__container">
|
||||||
<div id={tagNameToUse} className="ads__injected-video" style={{ display: 'none' }} />
|
<div id={adConfig.tag} className="ads__injected-video" style={{ display: 'none' }} />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={classnames('ads__claim-text', {
|
className={classnames('ads__claim-text', {
|
||||||
|
@ -145,7 +136,7 @@ function Ads(props: Props) {
|
||||||
// homepage ad in a card
|
// homepage ad in a card
|
||||||
const homepageCardAd = (
|
const homepageCardAd = (
|
||||||
<div className="homepageAdContainer media__thumb" style={{ display: 'none' }}>
|
<div className="homepageAdContainer media__thumb" style={{ display: 'none' }}>
|
||||||
<div id={tagNameToUse} className="homepageAdDiv media__thumb" style={{ display: 'none' }} />
|
<div id={adConfig.tag} className="homepageAdDiv media__thumb" style={{ display: 'none' }} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue