Skip to content

Commit 18e4b60

Browse files
committed
only render adportals component if is false
1 parent df2fa08 commit 18e4b60

File tree

8 files changed

+16
-24
lines changed

8 files changed

+16
-24
lines changed

dotcom-rendering/src/components/AdPortals.importable.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,11 @@ const debounceUpdateAds = libDebounce(updateAds, 100, { leading: true });
104104

105105
export const AdPortals = ({
106106
rightAlignFrom = 'desktop',
107-
shouldHideAds,
108107
}: {
109108
/** In most cases, we want to try to display ads in the right column from desktop upwards.
110109
* For blogs, we want right aligned from wide upwards.
111110
*/
112111
rightAlignFrom?: Breakpoint;
113-
/**
114-
* If the page data has been set to hide ads, we should respect that in not rendering placeholders
115-
*/
116-
shouldHideAds?: boolean;
117112
}) => {
118113
// Server-rendered placeholder elements for inline ad slots to be inserted into (below desktop breakpoint)
119114
const [adPlaceholders, setAdPlaceholders] = useState<Element[]>([]);
@@ -143,7 +138,7 @@ export const AdPortals = ({
143138
void getUserClient()
144139
.isPremium()
145140
.then((isPremium) => {
146-
if (!isPremium && !shouldHideAds) {
141+
if (!isPremium) {
147142
setAdPlaceholders(
148143
Array.from(
149144
document.getElementsByClassName(adPlaceholderClass),
@@ -157,7 +152,7 @@ export const AdPortals = ({
157152
}
158153
})
159154
.catch(() => console.error('Error setting up ads'));
160-
}, [shouldHideAds]);
155+
}, []);
161156

162157
/**
163158
* Insert Ads

dotcom-rendering/src/layouts/CommentLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ export const CommentLayout = (props: WebProps | AppsProps) => {
347347
)}
348348

349349
<main data-layout="CommentLayout">
350-
{isApps && (
350+
{isApps && !article.shouldHideAds && (
351351
<Island priority="critical">
352-
<AdPortals shouldHideAds={article.shouldHideAds} />
352+
<AdPortals />
353353
</Island>
354354
)}
355355
<Section

dotcom-rendering/src/layouts/ImmersiveLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,9 @@ export const ImmersiveLayout = (props: WebProps | AppProps) => {
437437
)}
438438

439439
<main data-layout="ImmersiveLayout">
440-
{isApps && (
440+
{isApps && !article.shouldHideAds && (
441441
<Island priority="critical">
442-
<AdPortals shouldHideAds={article.shouldHideAds} />
442+
<AdPortals />
443443
</Island>
444444
)}
445445
<Section

dotcom-rendering/src/layouts/InteractiveLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ export const InteractiveLayout = (props: WebProps | AppsProps) => {
324324
</>
325325
)}
326326
<main data-layout="InteractiveLayout">
327-
{isApps && (
327+
{isApps && !article.shouldHideAds && (
328328
<Island priority="critical">
329-
<AdPortals shouldHideAds={article.shouldHideAds} />
329+
<AdPortals />
330330
</Island>
331331
)}
332332
<Section

dotcom-rendering/src/layouts/LiveLayout.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,9 @@ export const LiveLayout = (props: WebProps | AppsProps) => {
361361
</Section>
362362
</Hide>
363363
)}
364-
{isApps && (
364+
{isApps && !article.shouldHideAds && (
365365
<Island priority="critical">
366-
<AdPortals
367-
rightAlignFrom="wide"
368-
shouldHideAds={article.shouldHideAds}
369-
/>
366+
<AdPortals rightAlignFrom="wide" />
370367
</Island>
371368
)}
372369
{footballMatchUrl ? (

dotcom-rendering/src/layouts/PictureLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ export const PictureLayout = (props: WebProps | AppsProps) => {
330330
lang={decideLanguage(article.lang)}
331331
dir={decideLanguageDirection(article.isRightToLeftLang)}
332332
>
333-
{isApps && (
333+
{isApps && !article.shouldHideAds && (
334334
<Island priority="critical">
335-
<AdPortals shouldHideAds={article.shouldHideAds} />
335+
<AdPortals />
336336
</Island>
337337
)}
338338
<Section

dotcom-rendering/src/layouts/ShowcaseLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ export const ShowcaseLayout = (props: WebProps | AppsProps) => {
371371
lang={decideLanguage(article.lang)}
372372
dir={decideLanguageDirection(article.isRightToLeftLang)}
373373
>
374-
{isApps && (
374+
{isApps && !article.shouldHideAds && (
375375
<Island priority="critical">
376-
<AdPortals shouldHideAds={article.shouldHideAds} />
376+
<AdPortals />
377377
</Island>
378378
)}
379379
<Section

dotcom-rendering/src/layouts/StandardLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,9 @@ export const StandardLayout = (props: WebProps | AppProps) => {
453453
)}
454454

455455
<main data-layout="StandardLayout">
456-
{isApps && (
456+
{isApps && !article.shouldHideAds && (
457457
<Island priority="critical">
458-
<AdPortals shouldHideAds={article.shouldHideAds} />
458+
<AdPortals />
459459
</Island>
460460
)}
461461
<Section

0 commit comments

Comments
 (0)