: undefined
: undefined;
- const userInterfaceLangId = !UserService.Instance.myUserInfo
- ? 0
- : getUserInterfaceLangId({
- myUserInfo: UserService.Instance.myUserInfo,
- allLanguages: this.props.allLanguages,
- });
+ const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
return (
<div
return this.props.iconVersion ? (
this.selectBtn
) : (
- <div className="language-select mb-3">
+ <div className="language-select row mb-3">
<label
className={classNames(
"col-form-label",
render() {
const url = this.state.form.url;
- const userInterfaceLangId = !UserService.Instance.myUserInfo
- ? 0
- : getUserInterfaceLangId({
- myUserInfo: UserService.Instance.myUserInfo,
- allLanguages: this.props.allLanguages,
- });
+ const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
return (
<form className="post-form" onSubmit={linkEvent(this, handlePostSubmit)}>
-import { Language, MyUserInfo } from "lemmy-js-client";
+import { Language } from "lemmy-js-client";
import { I18NextService } from "../../services/I18NextService";
-export default function getUserInterfaceLanguageId({
- myUserInfo,
- allLanguages,
-}: {
- myUserInfo: MyUserInfo;
- allLanguages: Language[];
-}): number {
+export default function getUserInterfaceLangId(
+ allLanguages: Language[]
+): number {
// Get the string of the browser- or user-defined language, like en-US
const i18nLang = I18NextService.i18n.language;
});
// Return the ID of that language object, or "0" for Undetermined
- return userLang.id || 0;
+ return userLang?.id || 0;
}