Fix locale fetch (#1017)

This commit is contained in:
saltrafael 2022-03-03 13:29:23 -03:00 committed by GitHub
parent 71589721ef
commit 7c304702d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -418,8 +418,12 @@ function App(props: Props) {
document.head.appendChild(secondScript); document.head.appendChild(secondScript);
} }
const shouldFetchLanguage = !localeLangs && !localeSwitchDismissed;
const shouldFetchGdpr = gdprRequired === null || gdprRequired === undefined;
if (shouldFetchLanguage || shouldFetchGdpr) {
fetchLocaleApi().then((response) => { fetchLocaleApi().then((response) => {
if (!localeLangs && !localeSwitchDismissed) { if (shouldFetchLanguage) {
const countryCode = response?.data?.country; const countryCode = response?.data?.country;
const langs = getLanguagesForCountry(countryCode); const langs = getLanguagesForCountry(countryCode);
@ -430,7 +434,7 @@ function App(props: Props) {
} }
// haven't done a gdpr check, do it now // haven't done a gdpr check, do it now
if (gdprRequired === null || gdprRequired === undefined) { if (shouldFetchGdpr) {
const gdprRequiredBasedOnLocation = response?.data?.gdpr_required; const gdprRequiredBasedOnLocation = response?.data?.gdpr_required;
// note we need gdpr and load script // note we need gdpr and load script
@ -446,6 +450,7 @@ function App(props: Props) {
} }
} }
}); });
}
return () => { return () => {
try { try {