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-2213 bugfix: Broken Next button #678

Guard against errors in case of unlisted or renamed chosen search

  • Loading branch information
wlycdgr committed Feb 4, 2021
commit fbf8b8bbc37ad3cac693fb3e75905bd763e464a4
@@ -12,6 +12,7 @@
*/

export const SET_DEFAULT_SEARCH = 'SET_DEFAULT_SEARCH';
export const DAWN_SETUP_NUMBER_FOR_UNLISTED_OR_RENAMED_SEARCH = 0;
export const SEARCH_GHOSTERY = 'Ghostery';
export const SEARCH_BING = 'Bing';
export const SEARCH_YAHOO = 'Yahoo';
@@ -27,3 +28,4 @@ export const SEARCH_QWANT = 'Qwant';
export const SEARCH_ENCRYPT = 'TODO: Add Search Encrypt browser.search.get() string';
export const SEARCH_TAILCAT = 'Tailcat';
export const SEARCH_OTHER = t('ghostery_dawn_onboarding_other');

@@ -32,7 +32,8 @@ import {
SEARCH_QWANT,
SEARCH_ENCRYPT,
SEARCH_TAILCAT,
SEARCH_OTHER
SEARCH_OTHER,
DAWN_SETUP_NUMBER_FOR_UNLISTED_OR_RENAMED_SEARCH
} from './ChooseDefaultSearchConstants';
import { Modal } from '../../../../shared-components';

@@ -161,9 +162,14 @@ class ChooseDefaultSearchView extends Component {

setDefaultSearch(chosenSearchName);

const chosenSearchNameIndex = searchSetupNumbers.indexOf(chosenSearchName);
const dawn_setup_number = (chosenSearchNameIndex === -1)
? DAWN_SETUP_NUMBER_FOR_UNLISTED_OR_RENAMED_SEARCH
: searchSetupNumbers[chosenSearchNameIndex].dawn_setup_number;

setSetupStep({
setup_step: CHOOSE_DEFAULT_SEARCH,
dawn_setup_number: searchSetupNumbers.find(elem => elem.name === chosenSearchName).dawn_setup_number,
dawn_setup_number,
origin: ONBOARDING
});
history.push(`/${ONBOARDING}/${CHOOSE_PLAN}`);
ProTip! Use n and p to navigate between commits in a pull request.