Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for GH-936 and for loading Human Web in Cliqz #36

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Next
Fix for Human Web loaded on Cliqz
  • Loading branch information
Serge Zarembsky
Serge Zarembsky committed Apr 12, 2018
commit c1566992490d4c9fd9d82f71c885b0afda9d464c
@@ -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);
}
}

/**
@@ -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,
@@ -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,14 @@ 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) {
} else {
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);
}

/**
@@ -785,26 +781,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 +1324,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 +1345,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 +1356,7 @@ function initializeGhosteryModules() {
}

cliqzStartup.then(() => {
if (!IS_EDGE) {
if (!IS_EDGE && !IS_CLIQZ) {
abtest.fetch().then(() => {
setupABTests();
}).catch((err) => {
ProTip! Use n and p to navigate between commits in a pull request.