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/readmes/%24%7B%60data:application/%7B%60%24%7BghostArchiveUrl%7D/static/git-favicon.png?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; }