From b2b61c26ef98eaf0f62707927debb4e1dc117365 Mon Sep 17 00:00:00 2001
From: Jenny <32821331+jenny-s51@users.noreply.github.com>
Date: Tue, 18 Jan 2022 18:48:32 -0500
Subject: [PATCH] Fixes localization 500 error (#1858)
* fix localization crash
* add optional chain on themeTypes object
* add comment
---
src/realm-settings/LocalizationTab.tsx | 42 +++++++++++++++-----------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/src/realm-settings/LocalizationTab.tsx b/src/realm-settings/LocalizationTab.tsx
index 6dd7a92215..ffe9d4641e 100644
--- a/src/realm-settings/LocalizationTab.tsx
+++ b/src/realm-settings/LocalizationTab.tsx
@@ -115,13 +115,18 @@ export const LocalizationTab = ({
useFetch(
async () => {
- let result = await adminClient.realms.getRealmLocalizationTexts({
- first,
- max,
- realm: realm.realm!,
- selectedLocale:
- selectMenuLocale || getValues("defaultLocale") || whoAmI.getLocale(),
- });
+ let result = await adminClient.realms
+ .getRealmLocalizationTexts({
+ first,
+ max,
+ realm: realm.realm!,
+ selectedLocale:
+ selectMenuLocale ||
+ getValues("defaultLocale") ||
+ whoAmI.getLocale(),
+ })
+ // prevents server error in dev mode due to snowpack
+ .catch(() => []);
const searchInBundles = (idx: number) => {
return Object.entries(result).filter((i) => i[idx].includes(filter));
@@ -405,17 +410,20 @@ export const LocalizationTab = ({
isOpen={supportedLocalesOpen}
placeholderText={t("selectLocales")}
>
- {themeTypes.login![0].locales.map(
- (locale: string, idx: number) => (
-
- {t(`allSupportedLocales.${locale}`)}
-
+ {
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ themeTypes.login![0].locales?.map(
+ (locale: string, idx: number) => (
+
+ {t(`allSupportedLocales.${locale}`)}
+
+ )
)
- )}
+ }
)}
/>