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

GH-2258: Preserve user onboarding settings #681

Merged
merged 10 commits into from Mar 15, 2021

Remove antiSuite wrapper, update checkbox

  • Loading branch information
leuryr committed Feb 19, 2021
commit ccfb5dcfecb78bfbe434049527ac6f9a172ba848
@@ -39,13 +39,12 @@ class BlockSettingsView extends Component {

componentDidMount() {
const { setupLifecycle: { blockSetupSeen } } = this.props;

if (blockSetupSeen) {
const {
antiSuite: {
enable_anti_tracking,
enable_ad_block,
enable_smart_block,
},
enable_anti_tracking,
enable_ad_block,
enable_smart_block,
blockingPolicy
} = this.props;

@@ -60,6 +59,24 @@ class BlockSettingsView extends Component {
}
}

componentDidUpdate() {
const {
recommendedChoices,
enable_anti_tracking,
enable_ad_block,
enable_smart_block,
kindsOfTrackers
} = this.state;

if (!recommendedChoices && kindsOfTrackers === 2 && enable_ad_block === true && enable_anti_tracking === true && enable_smart_block === true) {
// eslint-disable-next-line react/no-did-update-set-state
this.setState({ recommendedChoices: true });
} else if (recommendedChoices && (kindsOfTrackers !== 2 || enable_ad_block !== true || enable_anti_tracking !== true || enable_smart_block !== true)) {
// eslint-disable-next-line react/no-did-update-set-state
this.setState({ recommendedChoices: false });
}
}

decodeBlockingPolicy = (blockingPolicy) => {
let decodedPolicy;
if (typeof blockingPolicy === 'number') {
@@ -18,26 +18,24 @@ import {
} from '../constants/AntiSuiteConstants';

const initialState = {
antiSuite: {
enable_ad_block: false,
enable_anti_tracking: false,
enable_smart_block: false
}
enable_ad_block: false,
enable_anti_tracking: false,
enable_smart_block: false
};

function AntiSuiteReducer(state = initialState, action) {
switch (action.type) {
case SET_AD_BLOCK: {
const { enable_ad_block } = action.data;
return { ...state, antiSuite: { ...state.antiSuite, enable_ad_block } };
return { ...state, enable_ad_block };
}
case SET_ANTI_TRACKING: {
const { enable_anti_tracking } = action.data;
return { ...state, antiSuite: { ...state.antiSuite, enable_anti_tracking } };
return { ...state, enable_anti_tracking };
}
case SET_SMART_BLOCK: {
const { enable_smart_block } = action.data;
return { ...state, antiSuite: { ...state.antiSuite, enable_smart_block } };
return { ...state, enable_smart_block };
}

default: return state;
ProTip! Use n and p to navigate between commits in a pull request.