diff --git a/src/shared/components/comment/comment-form.tsx b/src/shared/components/comment/comment-form.tsx index 11366fc4..0226e23e 100644 --- a/src/shared/components/comment/comment-form.tsx +++ b/src/shared/components/comment/comment-form.tsx @@ -1,5 +1,5 @@ import { myAuthRequired } from "@utils/app"; -import getUserPrimaryLanguage from "@utils/app/user-primary-language"; +import getUserInterfaceLangId from "@utils/app/user-interface-language"; import { capitalizeFirstLetter } from "@utils/helpers"; import { Component } from "inferno"; import { T } from "inferno-i18next-dess"; @@ -41,9 +41,10 @@ export class CommentForm extends Component { : undefined : undefined; - const userPrimaryLanguage = getUserPrimaryLanguage( - UserService?.Instance?.myUserInfo - ); + const userInterfaceLangId = getUserInterfaceLangId({ + myUserInfo: UserService.Instance.myUserInfo, + allLanguages: this.props.allLanguages, + }); return (
{ {UserService.Instance.myUserInfo ? ( { } render() { - const userPrimaryLanguage = getUserPrimaryLanguage( - UserService?.Instance?.myUserInfo - ); - const url = this.state.form.url; + const userInterfaceLangId = getUserInterfaceLangId({ + myUserInfo: UserService.Instance.myUserInfo, + allLanguages: this.props.allLanguages, + }); + return (
{
{ + return i18nLang.indexOf(lang.code) === 0; + }); + + // Return the ID of that language object + return userLang.id || 0; +} diff --git a/src/shared/utils/app/user-primary-language.ts b/src/shared/utils/app/user-primary-language.ts deleted file mode 100644 index 06ae2595..00000000 --- a/src/shared/utils/app/user-primary-language.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { UserService } from "../../services"; - -export default function getUserPrimaryLanguage( - myUserInfo = UserService.Instance.myUserInfo -): number { - // Get first language in discussion languages array that isn't equal to "0", - // which is the language selection "Undetermined" - return myUserInfo?.discussion_languages.find(lang => lang !== 0) || 0; -}