Skip to content

Commit

Permalink
improve readability of desktop ad position logic
Browse files Browse the repository at this point in the history
  • Loading branch information
cemms1 committed Jan 20, 2025
1 parent 89499f3 commit 79aa7c1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions dotcom-rendering/src/lib/getFrontsAdPositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ const getFrontsBannerAdPositions = (
const isMaxAdsReached = adPositions.length >= MAX_FRONTS_BANNER_ADS;

if (isFinalCollection || isMaxAdsReached) {
// Stop inserting adverts all together
return accumulator;
}

const collectionHeight = getCollectionHeight(collection);
const prevCollection = collections[index - 1];
const isFirstCollection = isUndefined(prevCollection);

Expand All @@ -313,19 +313,19 @@ const getFrontsBannerAdPositions = (
prevCollection,
)
) {
// Inserting an ad, resetting the height since ad
// Inserting advert, resetting the height since ad
// to the height of the current collection
return {
...accumulator,
adPositions: [...adPositions, index],
heightSinceAd: collectionHeight,
heightSinceAd: getCollectionHeight(collection),
};
} else {
// Not inserting ad, moving onto next container and
// adding the height onto the height since ad
// Not inserting advert, moving onto the next container
// and increasing the height since ad
return {
...accumulator,
heightSinceAd: (accumulator.heightSinceAd +=
collectionHeight),
adPositions,
heightSinceAd:
heightSinceAd + getCollectionHeight(collection),
};
}
},
Expand Down

0 comments on commit 79aa7c1

Please sign in to comment.