From ccf0a6dbaa86fbc755cdfcce2481eebac338b768 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Fri, 23 Jun 2023 17:21:10 -0400 Subject: [PATCH] fix: Fix language selection bug --- src/shared/components/comment/comment-form.tsx | 10 ++++++---- src/shared/components/common/markdown-textarea.tsx | 6 +++++- src/shared/components/post/post-form.tsx | 10 ++++++---- src/shared/utils/app/user-interface-language.ts | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) 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; } -- 2.44.1