Fix crash in /about
when server returns cached rules without translations
attribute (#34997)
This commit is contained in:
parent
1824b1fd29
commit
c727701839
1 changed files with 12 additions and 4 deletions
|
@ -29,7 +29,7 @@ interface BaseRule {
|
||||||
|
|
||||||
interface Rule extends BaseRule {
|
interface Rule extends BaseRule {
|
||||||
id: string;
|
id: string;
|
||||||
translations: Record<string, BaseRule>;
|
translations?: Record<string, BaseRule>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RulesSection: FC<RulesSectionProps> = ({ isLoading = false }) => {
|
export const RulesSection: FC<RulesSectionProps> = ({ isLoading = false }) => {
|
||||||
|
@ -113,15 +113,23 @@ const rulesSelector = createSelector(
|
||||||
(rules, locale): Rule[] => {
|
(rules, locale): Rule[] => {
|
||||||
return rules.map((rule) => {
|
return rules.map((rule) => {
|
||||||
const translations = rule.translations;
|
const translations = rule.translations;
|
||||||
if (translations[locale]) {
|
|
||||||
rule.text = translations[locale].text;
|
// Handle cached responses from earlier versions
|
||||||
rule.hint = translations[locale].hint;
|
if (!translations) {
|
||||||
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
const partialLocale = locale.split('-')[0];
|
const partialLocale = locale.split('-')[0];
|
||||||
if (partialLocale && translations[partialLocale]) {
|
if (partialLocale && translations[partialLocale]) {
|
||||||
rule.text = translations[partialLocale].text;
|
rule.text = translations[partialLocale].text;
|
||||||
rule.hint = translations[partialLocale].hint;
|
rule.hint = translations[partialLocale].hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (translations[locale]) {
|
||||||
|
rule.text = translations[locale].text;
|
||||||
|
rule.hint = translations[locale].hint;
|
||||||
|
}
|
||||||
|
|
||||||
return rule;
|
return rule;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue