From: Jay Sitter Date: Fri, 23 Jun 2023 21:21:10 +0000 (-0400) Subject: fix: Fix language selection bug X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/README.ja.md?a=commitdiff_plain;h=ccf0a6dbaa86fbc755cdfcce2481eebac338b768;p=lemmy-ui.git fix: Fix language selection bug --- diff --git a/src/shared/components/comment/comment-form.tsx b/src/shared/components/comment/comment-form.tsx index 0226e23..5cce2b5 100644 --- a/src/shared/components/comment/comment-form.tsx +++ b/src/shared/components/comment/comment-form.tsx @@ -41,10 +41,12 @@ export class CommentForm extends Component { : undefined : undefined; - const userInterfaceLangId = getUserInterfaceLangId({ - myUserInfo: UserService.Instance.myUserInfo, - allLanguages: this.props.allLanguages, - }); + const userInterfaceLangId = !UserService.Instance.myUserInfo + ? 0 + : getUserInterfaceLangId({ + myUserInfo: UserService.Instance.myUserInfo, + allLanguages: this.props.allLanguages, + }); return (
{ render() { const url = this.state.form.url; - const userInterfaceLangId = getUserInterfaceLangId({ - myUserInfo: UserService.Instance.myUserInfo, - allLanguages: this.props.allLanguages, - }); + const userInterfaceLangId = !UserService.Instance.myUserInfo + ? 0 + : getUserInterfaceLangId({ + myUserInfo: UserService.Instance.myUserInfo, + allLanguages: this.props.allLanguages, + }); return (
diff --git a/src/shared/utils/app/user-interface-language.ts b/src/shared/utils/app/user-interface-language.ts index 5ccd61c..707526d 100644 --- a/src/shared/utils/app/user-interface-language.ts +++ b/src/shared/utils/app/user-interface-language.ts @@ -17,6 +17,6 @@ export default function getUserInterfaceLanguageId({ return i18nLang.indexOf(lang.code) === 0; }); - // Return the ID of that language object + // Return the ID of that language object, or "0" for Undetermined return userLang.id || 0; }