From: Jay Sitter Date: Fri, 23 Jun 2023 19:14:16 +0000 (-0400) Subject: fix: Use Interface Language instead X-Git-Url: http://these/git/%24%7BgetStaticDir%28%29%7D/styles/%7B%60https:/%24%7Bargs.thread.url%7D?a=commitdiff_plain;h=bf54d404335a43ea15a9162171249d1fc3ba8782;p=lemmy-ui.git fix: Use Interface Language instead --- diff --git a/src/shared/components/comment/comment-form.tsx b/src/shared/components/comment/comment-form.tsx index 11366fc..0226e23 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 06ae259..0000000 --- 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; -}