From c7277018394335f5950e1f235b0995c53b129f85 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 10 Jun 2025 15:25:24 +0200 Subject: [PATCH] Fix crash in `/about` when server returns cached rules without `translations` attribute (#34997) --- .../mastodon/features/about/components/rules.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/javascript/mastodon/features/about/components/rules.tsx b/app/javascript/mastodon/features/about/components/rules.tsx index 063b6b48ec..e413adb310 100644 --- a/app/javascript/mastodon/features/about/components/rules.tsx +++ b/app/javascript/mastodon/features/about/components/rules.tsx @@ -29,7 +29,7 @@ interface BaseRule { interface Rule extends BaseRule { id: string; - translations: Record; + translations?: Record; } export const RulesSection: FC = ({ isLoading = false }) => { @@ -113,15 +113,23 @@ const rulesSelector = createSelector( (rules, locale): Rule[] => { return rules.map((rule) => { const translations = rule.translations; - if (translations[locale]) { - rule.text = translations[locale].text; - rule.hint = translations[locale].hint; + + // Handle cached responses from earlier versions + if (!translations) { + return rule; } + const partialLocale = locale.split('-')[0]; if (partialLocale && translations[partialLocale]) { rule.text = translations[partialLocale].text; rule.hint = translations[partialLocale].hint; } + + if (translations[locale]) { + rule.text = translations[locale].text; + rule.hint = translations[locale].hint; + } + return rule; }); },