diff --git a/app/setup/components/Views/AdditionalFeaturesView.jsx b/app/setup/components/Views/AdditionalFeaturesView.jsx index 01bff90f7..913f06e40 100644 --- a/app/setup/components/Views/AdditionalFeaturesView.jsx +++ b/app/setup/components/Views/AdditionalFeaturesView.jsx @@ -45,7 +45,9 @@ class AdditionalFeaturesView extends Component { * @param {Object} event The event created by the onChange property */ _handleAntiTrack = (event) => { - this.props.actions.updateAntiTrack(event.target.checked); + if (!IS_CLIQZ) { + this.props.actions.updateAntiTrack(event.target.checked); + } } /** @@ -61,7 +63,9 @@ class AdditionalFeaturesView extends Component { * @param {Object} event The event created by the onChange property */ _handleAdBlock = (event) => { - this.props.actions.updateAdBlock(event.target.checked); + if (!IS_CLIQZ) { + this.props.actions.updateAdBlock(event.target.checked); + } } /** diff --git a/app/setup/reducers/additionalFeatures.js b/app/setup/reducers/additionalFeatures.js index aa5dd3e33..08a669898 100644 --- a/app/setup/reducers/additionalFeatures.js +++ b/app/setup/reducers/additionalFeatures.js @@ -40,6 +40,9 @@ const initialState = { export default (state = initialState, action) => { switch (action.type) { case UPDATE_ANTITRACK: { + if (IS_CLIQZ) { + return state; + } msg.sendMessage('updateAntiTrack', action.data); return Object.assign({}, state, { antiTrack: action.data, @@ -52,6 +55,9 @@ export default (state = initialState, action) => { }); } case UPDATE_ADBLOCK: { + if (IS_CLIQZ) { + return state; + } msg.sendMessage('updateAdBlock', action.data); return Object.assign({}, state, { adBlock: action.data, diff --git a/src/background.js b/src/background.js index 2382bd142..89985f930 100644 --- a/src/background.js +++ b/src/background.js @@ -71,8 +71,6 @@ const { adblocker, antitracking, hpn } = cliqz.modules; const messageCenter = cliqz.modules['message-center']; const offers = cliqz.modules['offers-v2']; -const CORRECT_STATE = 'CorrectState'; - /** * Enable or disable specified module. * @memberOf Background @@ -81,16 +79,13 @@ const CORRECT_STATE = 'CorrectState'; * @return {Promise} */ function setCliqzModuleEnabled(module, enabled) { - if (enabled && !module.isEnabled) { + if (enabled) { log('SET CLIQZ MODULE ENABLED', module); return cliqz.enableModule(module.name); - } else if (!enabled && module.isEnabled) { - log('SET CLIQZ MODULE DISABLED', module); - cliqz.disableModule(module.name); - return Promise.resolve(); } - log('MODULE IS ALREADY IN CORRECT STATE', module, enabled); - return Promise.resolve(CORRECT_STATE); + log('SET CLIQZ MODULE DISABLED', module); + cliqz.disableModule(module.name); + return Promise.resolve(); } /** @@ -785,26 +780,32 @@ function initializeDispatcher() { dispatcher.on('conf.save.enable_human_web', (enableHumanWeb) => { if (!IS_EDGE && !IS_CLIQZ) { setCliqzModuleEnabled(humanweb, enableHumanWeb).then((data) => { - if (data !== CORRECT_STATE) { - // We don't want to affect Offers here - setupABTestAntitracking(); - } + // We don't want to affect Offers here + setupABTestAntitracking(); }); + } else { + setCliqzModuleEnabled(humanweb, false); } }); dispatcher.on('conf.save.enable_offers', (enableOffers) => { if (!IS_EDGE && !IS_CLIQZ) { setCliqzModuleEnabled(offers, enableOffers); + } else { + setCliqzModuleEnabled(offers, false); } }); dispatcher.on('conf.save.enable_anti_tracking', (enableAntitracking) => { if (!IS_CLIQZ) { setCliqzModuleEnabled(antitracking, enableAntitracking); + } else { + setCliqzModuleEnabled(antitracking, false); } }); dispatcher.on('conf.save.enable_ad_block', (enableAdBlock) => { if (!IS_CLIQZ) { setCliqzModuleEnabled(adblocker, enableAdBlock); + } else { + setCliqzModuleEnabled(adblocker, false); } }); @@ -1322,16 +1323,14 @@ function initializeGhosteryModules() { if (globals.JUST_UPGRADED_FROM_7) { conf.enable_ad_block = false; conf.enable_anti_tracking = false; - setCliqzModuleEnabled(antitracking, conf.enable_anti_tracking); - setCliqzModuleEnabled(adblocker, conf.enable_ad_block); - setCliqzModuleEnabled(humanweb, IS_EDGE ? false : conf.enable_human_web); + conf.enable_human_web = (IS_EDGE || IS_CLIQZ) ? false : conf.enable_human_web; } else { - conf.enable_ad_block = !adblocker.isDisabled; - conf.enable_anti_tracking = !antitracking.isDisabled; - conf.enable_human_web = IS_EDGE ? false : !humanweb.isDisabled; + conf.enable_ad_block = IS_CLIQZ ? false : !adblocker.isDisabled; + conf.enable_anti_tracking = IS_CLIQZ ? false : !antitracking.isDisabled; + conf.enable_human_web = (IS_EDGE || IS_CLIQZ) ? false : !humanweb.isDisabled; } // sync conf from module status - conf.enable_offers = IS_EDGE ? false : !offers.isDisabled; + conf.enable_offers = (IS_EDGE || IS_CLIQZ) ? false : !offers.isDisabled; })).catch((e) => { log('cliqzStartup error', e); }); @@ -1345,7 +1344,7 @@ function initializeGhosteryModules() { // auto-fetch from CMP cmp.fetchCMPData(); - if (!IS_EDGE) { + if (!IS_EDGE && !IS_CLIQZ) { // auto-fetch human web offer abtest.fetch().then(() => { setupABTests(); @@ -1356,7 +1355,7 @@ function initializeGhosteryModules() { } cliqzStartup.then(() => { - if (!IS_EDGE) { + if (!IS_EDGE && !IS_CLIQZ) { abtest.fetch().then(() => { setupABTests(); }).catch((err) => {