fix: Fix up some interface language logic and design

This commit is contained in:
Jay Sitter 2023-06-24 00:03:49 -04:00
parent 35d20491ea
commit 8184e33c9f
4 changed files with 8 additions and 22 deletions

View file

@ -41,12 +41,7 @@ export class CommentForm extends Component<CommentFormProps, any> {
: undefined : undefined
: undefined; : undefined;
const userInterfaceLangId = !UserService.Instance.myUserInfo const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
? 0
: getUserInterfaceLangId({
myUserInfo: UserService.Instance.myUserInfo,
allLanguages: this.props.allLanguages,
});
return ( return (
<div <div

View file

@ -49,7 +49,7 @@ export class LanguageSelect extends Component<LanguageSelectProps, any> {
return this.props.iconVersion ? ( return this.props.iconVersion ? (
this.selectBtn this.selectBtn
) : ( ) : (
<div className="language-select mb-3"> <div className="language-select row mb-3">
<label <label
className={classNames( className={classNames(
"col-form-label", "col-form-label",

View file

@ -326,12 +326,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
render() { render() {
const url = this.state.form.url; const url = this.state.form.url;
const userInterfaceLangId = !UserService.Instance.myUserInfo const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
? 0
: getUserInterfaceLangId({
myUserInfo: UserService.Instance.myUserInfo,
allLanguages: this.props.allLanguages,
});
return ( return (
<form className="post-form" onSubmit={linkEvent(this, handlePostSubmit)}> <form className="post-form" onSubmit={linkEvent(this, handlePostSubmit)}>

View file

@ -1,13 +1,9 @@
import { Language, MyUserInfo } from "lemmy-js-client"; import { Language } from "lemmy-js-client";
import { I18NextService } from "../../services/I18NextService"; import { I18NextService } from "../../services/I18NextService";
export default function getUserInterfaceLanguageId({ export default function getUserInterfaceLangId(
myUserInfo, allLanguages: Language[]
allLanguages, ): number {
}: {
myUserInfo: MyUserInfo;
allLanguages: Language[];
}): number {
// Get the string of the browser- or user-defined language, like en-US // Get the string of the browser- or user-defined language, like en-US
const i18nLang = I18NextService.i18n.language; const i18nLang = I18NextService.i18n.language;
@ -18,5 +14,5 @@ export default function getUserInterfaceLanguageId({
}); });
// Return the ID of that language object, or "0" for Undetermined // Return the ID of that language object, or "0" for Undetermined
return userLang.id || 0; return userLang?.id || 0;
} }