]> Untitled Git - lemmy-ui.git/commitdiff
fix: Fix up some interface language logic and design
authorJay Sitter <jay@jaysitter.com>
Sat, 24 Jun 2023 04:03:49 +0000 (00:03 -0400)
committerJay Sitter <jay@jaysitter.com>
Sat, 24 Jun 2023 04:44:01 +0000 (00:44 -0400)
src/shared/components/comment/comment-form.tsx
src/shared/components/common/language-select.tsx
src/shared/components/post/post-form.tsx
src/shared/utils/app/user-interface-language.ts

index 5cce2b5322694fc025ea9a695a2ef37b96ba6937..c9937c6292b6771fe43134a4cf0402becff56015 100644 (file)
@@ -41,12 +41,7 @@ export class CommentForm extends Component<CommentFormProps, any> {
           : 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
index c74f24cd6d1a88258ce0e13a3a7a4d62d2f71737..03d868bea7018ee001ed0517b573bc28d9752dc2 100644 (file)
@@ -49,7 +49,7 @@ export class LanguageSelect extends Component<LanguageSelectProps, any> {
     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",
index 780ea797af2bc8527bb01740706387177138bf16..ebea432479d69fabf3dc7d3ed984d317820f8132 100644 (file)
@@ -326,12 +326,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
   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)}>
index 707526d780ec856511ac11978f5e861112c4b4f9..ff2e4390a048eb55b627088dcbeb60cb1eb3687b 100644 (file)
@@ -1,13 +1,9 @@
-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;
 
@@ -18,5 +14,5 @@ export default function getUserInterfaceLanguageId({
   });
 
   // Return the ID of that language object, or "0" for Undetermined
-  return userLang.id || 0;
+  return userLang?.id || 0;
 }