Skip to content

Commit

Permalink
feat(smartNTT): process assets in new campaign array
Browse files Browse the repository at this point in the history
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 brave/ntp-si-assets#1192.
  • Loading branch information
tackley committed Oct 16, 2024
1 parent 35f5bb8 commit ccce547
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/ntpUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ccce547

Please sign in to comment.