Prevent invalid locale from being loaded (#2099)

This commit is contained in:
Eric Bailey 2023-12-05 19:51:50 -06:00 committed by GitHub
parent fab9f839d0
commit a915a57b10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 14 deletions

View file

@ -48,6 +48,7 @@ export function LanguageSettingsScreen(_props: Props) {
const onChangePrimaryLanguage = React.useCallback(
(value: Parameters<PickerSelectProps['onValueChange']>[0]) => {
if (!value) return
if (langPrefs.primaryLanguage !== value) {
setLangPrefs.setPrimaryLanguage(value)
}
@ -57,6 +58,7 @@ export function LanguageSettingsScreen(_props: Props) {
const onChangeAppLanguage = React.useCallback(
(value: Parameters<PickerSelectProps['onValueChange']>[0]) => {
if (!value) return
if (langPrefs.appLanguage !== value) {
setLangPrefs.setAppLanguage(value)
}
@ -100,6 +102,7 @@ export function LanguageSettingsScreen(_props: Props) {
<View style={{position: 'relative'}}>
<RNPickerSelect
placeholder={{}}
value={langPrefs.appLanguage}
onValueChange={onChangeAppLanguage}
items={APP_LANGUAGES.filter(l => Boolean(l.code2)).map(l => ({
@ -190,6 +193,7 @@ export function LanguageSettingsScreen(_props: Props) {
<View style={{position: 'relative'}}>
<RNPickerSelect
placeholder={{}}
value={langPrefs.primaryLanguage}
onValueChange={onChangePrimaryLanguage}
items={LANGUAGES.filter(l => Boolean(l.code2)).map(l => ({