From 6546eaeb6398317c3ea2270179e63b0d6556ded8 Mon Sep 17 00:00:00 2001 From: mayeaux Date: Mon, 15 Nov 2021 16:01:42 +0100 Subject: [PATCH] refactor ad code and dont show ads on embeds (#290) --- ui/component/viewers/videoViewer/internal/ads.js | 4 ++-- ui/component/viewers/videoViewer/internal/videojs.jsx | 2 +- ui/component/viewers/videoViewer/view.jsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/component/viewers/videoViewer/internal/ads.js b/ui/component/viewers/videoViewer/internal/ads.js index 7dbbe015d..0c97b32bf 100644 --- a/ui/component/viewers/videoViewer/internal/ads.js +++ b/ui/component/viewers/videoViewer/internal/ads.js @@ -51,7 +51,7 @@ const hitsAtFiftyPercentChance = hitsFiftyPercent(); * @param allowPreRoll * @param player */ -function runAds(internalFeatureEnabled, allowPreRoll, player) { +function runAds(internalFeatureEnabled, allowPreRoll, player, embedded) { // current timestamp for vpaid const timestamp = new Date().toISOString(); @@ -83,7 +83,7 @@ function runAds(internalFeatureEnabled, allowPreRoll, player) { // always have ads on if internal feature is on, // otherwise if not authed, roll for 20% to see an ad // allowPreRoll currently means unauthenticated (don't show to logged in users) - const shouldShowAnAd = internalFeatureEnabled || (allowPreRoll && hitsAtFiftyPercentChance); + const shouldShowAnAd = internalFeatureEnabled || (!embedded && allowPreRoll && hitsAtFiftyPercentChance); if (shouldShowAnAd && browserIsChrome && !IS_MOBILE) { // fire up ima integration via module diff --git a/ui/component/viewers/videoViewer/internal/videojs.jsx b/ui/component/viewers/videoViewer/internal/videojs.jsx index 4075226a4..69beb04e6 100644 --- a/ui/component/viewers/videoViewer/internal/videojs.jsx +++ b/ui/component/viewers/videoViewer/internal/videojs.jsx @@ -183,7 +183,7 @@ export default React.memo(function VideoJs(props: Props) { // this seems like a weird thing to have to check for here if (!player) return; - runAds(internalFeatureEnabled, allowPreRoll, player); + runAds(internalFeatureEnabled, allowPreRoll, player, embedded); initializeEvents(); diff --git a/ui/component/viewers/videoViewer/view.jsx b/ui/component/viewers/videoViewer/view.jsx index 3e43616e6..30c1a6c56 100644 --- a/ui/component/viewers/videoViewer/view.jsx +++ b/ui/component/viewers/videoViewer/view.jsx @@ -470,7 +470,7 @@ function VideoViewer(props: Props) { autoplaySetting={autoplayNext} claimId={claimId} userId={userId} - allowPreRoll={!authenticated} // used to not include embeds, removed for now + allowPreRoll={!authenticated} // TODO: pull this into ads functionality so it's self contained internalFeatureEnabled={internalFeature} shareTelemetry={shareTelemetry} replay={replay}