From ccce5478b2cf6401069420b58b8b3fb928840829 Mon Sep 17 00:00:00 2001 From: Graham Tackley Date: Wed, 16 Oct 2024 11:37:55 +0100 Subject: [PATCH] feat(smartNTT): process assets in new campaign array SmartNTTs are targeted locally by the browser, and only shown to users if the configured conditions match. Non-smart capable browsers - that pre-date the introduction of this feature - should never show these NTTs. To enforce this: - the existing campaigns array in photo.json never includes smartNTTs - a new campaigns2 array is included in photo.json. This includes all NTTs, including smart ones. SmartNTT capable browsers read the campaigns2 array. Non-smart capable browsers continue to read the campaigns array. Assets referenced in either of these arrays need to be included within the crx package. See https://github.com/brave/ntp-si-assets/pull/1192. --- lib/ntpUtil.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ntpUtil.js b/lib/ntpUtil.js index d151f68f..b5cdb813 100644 --- a/lib/ntpUtil.js +++ b/lib/ntpUtil.js @@ -15,7 +15,7 @@ const jsonSchemaVersion = 1 * @typedef {{ imageUrl: string }} Logo * @typedef {{ logo?: Logo, imageUrl: string}} Wallpaper * @typedef {{ logo: Logo, wallpapers: Wallpaper[]}} Campaign -* @typedef {Campaign & { campaigns?: Campaign[], topSites?: { iconUrl }[] }} NTPAssetSchema +* @typedef {Campaign & { campaigns?: Campaign[], campaigns2?: Campaign[], topSites?: { iconUrl }[] }} NTPAssetSchema */ const createPhotoJsonFile = (path, body) => { @@ -58,6 +58,11 @@ const getImageFileNameListFrom = (photoJsonObj) => { getImageFileNameListFromCampaign(campaign).forEach(s => fileList.add(s)) } } + if (photoJsonObj.campaigns2) { + for (const campaign of photoJsonObj.campaigns2) { + getImageFileNameListFromCampaign(campaign).forEach(s => fileList.add(s)) + } + } if (photoJsonObj.topSites) { photoJsonObj.topSites.forEach((topSiteObj) => { fileList.add(topSiteObj.iconUrl)