Skip to content

Commit

Permalink
fix: [#173530583] fix (#1967)
Browse files Browse the repository at this point in the history
  • Loading branch information
Undermaken authored Jun 26, 2020
1 parent dbe7d5d commit f982d31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 11 additions & 4 deletions ts/store/reducers/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ export const idpContextualHelpDataFromIdSelector = (id: IdentityProviderId) =>
return pot.getOrElse(
pot.map(contextualHelpData, data => {
const locale = getLocalePrimaryWithFallback();
return fromNullable(data[locale].idps[id]);
return fromNullable(
data[locale] !== undefined ? data[locale].idps[id] : undefined
);
}),
none
);
Expand All @@ -176,9 +178,14 @@ export const screenContextualHelpDataSelector = createSelector<
return none;
}
const locale = getLocalePrimaryWithFallback();
const screenData = data[locale].screens.find(
s => s.route_name.toLowerCase() === currentRouteName.toLocaleLowerCase()
);
const screenData =
data[locale] !== undefined
? data[locale].screens.find(
s =>
s.route_name.toLowerCase() ===
currentRouteName.toLocaleLowerCase()
)
: undefined;
return fromNullable(screenData);
});
});
Expand Down
3 changes: 2 additions & 1 deletion ts/utils/locale.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Option, some } from "fp-ts/lib/Option";
import { Locales } from "../../locales/locales";
import I18n from "../i18n";
import I18n, { translations } from "../i18n";
/**
* Helpers for handling locales
*/
Expand All @@ -21,5 +21,6 @@ export function getLocalePrimary(

export const getLocalePrimaryWithFallback = (fallback: Locales = "en") =>
getLocalePrimary(I18n.currentLocale())
.filter(l => Object.keys(translations).some(t => t === l))
.map(s => s as Locales)
.getOrElse(fallback);

0 comments on commit f982d31

Please sign in to comment.