Skip to content

Commit 4c3395b

Browse files
committed
Populate default styles on load
1 parent 3b833c7 commit 4c3395b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/features/click-to-load.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const titleID = 'DuckDuckGoPrivacyEssentialsCTLElementTitle'
2222
// @see {getConfig}
2323
let config = null
2424
let sharedStrings = null
25-
let styles = null
25+
let styles = getStyles()
2626

2727
// TODO: Remove these redundant data structures and refactor the related code.
2828
// There should be no need to have the entity configuration stored in two
@@ -1618,10 +1618,13 @@ export default class ClickToLoad extends ContentFeature {
16181618
const websiteOwner = args?.site?.parentEntity
16191619
const settings = args?.featureSettings?.clickToLoad || {}
16201620
const locale = args?.locale || 'en'
1621-
const localizedConfig = getConfig(locale, args?.assets)
1621+
const localizedConfig = getConfig(locale)
16221622
config = localizedConfig.config
16231623
sharedStrings = localizedConfig.sharedStrings
1624-
styles = localizedConfig.styles
1624+
// update styles if asset config was sent
1625+
if (args?.assets) {
1626+
styles = getStyles(args.assets)
1627+
}
16251628

16261629
for (const entity of Object.keys(config)) {
16271630
// Strip config entities that are first-party, or aren't enabled in the

src/features/click-to-load/ctl-config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import localesJSON from '../../../build/locales/ctl-locales.js'
1616
/**
1717
* Get CSS style defintions for CTL, using the provided AssetConfig for any non-embedded assets
1818
* (e.g. fonts.)
19-
* @param {AssetConfig} assets
19+
* @param {AssetConfig} [assets]
2020
*/
2121
export function getStyles (assets) {
2222
let fontStyle = ''
@@ -624,15 +624,13 @@ export function getStyles (assets) {
624624

625625
/**
626626
* @param {string} locale UI locale
627-
* @param {AssetConfig} assets Config for UI assets
628627
*/
629-
export function getConfig (locale, assets) {
628+
export function getConfig (locale) {
630629
const locales = JSON.parse(localesJSON)
631630
const fbStrings = locales[locale]['facebook.json']
632631
const ytStrings = locales[locale]['youtube.json']
633632

634633
const sharedStrings = locales[locale]['shared.json']
635-
const styles = getStyles(assets)
636634
const config = {
637635
'Facebook, Inc.': {
638636
informationalModal: {
@@ -1041,5 +1039,5 @@ export function getConfig (locale, assets) {
10411039
}
10421040
}
10431041

1044-
return { config, sharedStrings, styles }
1042+
return { config, sharedStrings }
10451043
}

0 commit comments

Comments
 (0)