diff --git a/src/scripts/userview/userview_modal.js b/src/scripts/userview/userview_modal.js index 9672189f..7520cc98 100644 --- a/src/scripts/userview/userview_modal.js +++ b/src/scripts/userview/userview_modal.js @@ -25,7 +25,7 @@ import * as AdvancedSettingsStandard from './view/oil.advanced.settings.standard import * as AdvancedSettingsTabs from './view/oil.advanced.settings.tabs'; import { logError, logInfo } from '../core/core_log'; import { getCpcType, getTheme, getTimeOutValue, isOptoutConfirmRequired, isPersistMinimumTracking } from './userview_config'; -import { gdprApplies, getAdvancedSettingsPurposesDefault, getInfoBannerOnly, isPoiActive } from '../core/core_config'; +import { gdprApplies, getAdvancedSettingsPurposesDefault, getInfoBannerOnly, isPoiActive, getCustomPurposeIds } from '../core/core_config'; import { applyPrivacySettings, getPrivacySettings, getSoiConsentData } from './userview_privacy'; import { activateOptoutConfirm } from './userview_optout_confirm'; import { getPurposeIds, loadVendorListAndCustomVendorList } from '../core/core_vendor_lists'; @@ -96,7 +96,7 @@ export function oilShowPreferenceCenter() { if (consentData) { currentPrivacySettings = consentData.getPurposesAllowed(); } else { - currentPrivacySettings = getAdvancedSettingsPurposesDefault() ? getPurposeIds() : []; + currentPrivacySettings = getAdvancedSettingsPurposesDefault() ? [...getPurposeIds(), ...getCustomPurposeIds()] : []; } applyPrivacySettings(currentPrivacySettings); }); diff --git a/src/scripts/userview/userview_privacy.js b/src/scripts/userview/userview_privacy.js index bfc83d96..1e06bd8b 100644 --- a/src/scripts/userview/userview_privacy.js +++ b/src/scripts/userview/userview_privacy.js @@ -2,7 +2,6 @@ import {getSoiCookie} from '../core/core_cookies'; import {PRIVACY_FULL_TRACKING} from '../core/core_constants'; import {logInfo} from '../core/core_log'; import {forEach} from './userview_modal'; -import {getPurposes} from '../core/core_vendor_lists'; export function getSoiConsentData() { let soiCookie = getSoiCookie(); @@ -33,19 +32,18 @@ export function getPrivacySettings() { export function applyPrivacySettings(allowedPurposes) { logInfo('Apply privacy settings from cookie', allowedPurposes); - for (let i = 1; i <= getPurposes().length; i++) { - document.querySelector(`#as-js-purpose-slider-${i}`).checked = (allowedPurposes.indexOf(i) !== -1); - } - if (allowedPurposes === 1) { forEach(document.querySelectorAll('.as-js-purpose-slider'), (domNode) => { domNode && (domNode.checked = true); }); - } - - if (allowedPurposes === 0) { + } else if (allowedPurposes === 0) { forEach(document.querySelectorAll('.as-js-purpose-slider'), (domNode) => { domNode && (domNode.checked = false); }); + } else if (allowedPurposes) { + allowedPurposes.map(function(allowedPurpose) { + document.querySelector(`#as-js-purpose-slider-${allowedPurpose}`).checked = (allowedPurpose !== -1); + }); } + }