Skip to content

Commit b539a93

Browse files
authored
Merge pull request #262 from IFRCGo/fix/empty-translations
Filter out empty translations from server
2 parents 4e602bb + 7c7b8dc commit b539a93

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/views/RootLayout/index.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
mapToList,
1717
mapToMap,
1818
isFalsyString,
19+
isDefined,
1920
} from '@togglecorp/fujs';
2021
import { Outlet, useNavigation } from 'react-router-dom';
2122

@@ -77,7 +78,17 @@ export function Component() {
7778
onSuccess: (response, { pages }) => {
7879
const stringMap = mapToMap(
7980
listToGroupList(
80-
response.strings,
81+
response.strings?.map(({ value, page_name, ...otherArgs }) => {
82+
// NOTE: removing empty translations or translations without pages
83+
if (isFalsyString(value) || isFalsyString(page_name)) {
84+
return undefined;
85+
}
86+
return {
87+
value,
88+
page_name,
89+
...otherArgs,
90+
};
91+
}).filter(isDefined),
8192
({ page_name }) => page_name ?? 'common',
8293
),
8394
(key) => key,

0 commit comments

Comments
 (0)