]> Untitled Git - lemmy-ui.git/commitdiff
Revert #1463, markdown default lang select
authorJay Sitter <jay@jaysitter.com>
Wed, 28 Jun 2023 12:42:55 +0000 (08:42 -0400)
committerJay Sitter <jay@jaysitter.com>
Wed, 28 Jun 2023 12:44:39 +0000 (08:44 -0400)
src/shared/components/comment/comment-form.tsx
src/shared/components/common/language-select.tsx
src/shared/components/common/markdown-textarea.tsx
src/shared/components/post/post-form.tsx
src/shared/utils/app/index.ts
src/shared/utils/app/user-interface-language.ts [deleted file]

index c9937c6292b6771fe43134a4cf0402becff56015..294960a812d35711983c4e33728189ae74fb7e36 100644 (file)
@@ -1,5 +1,4 @@
 import { myAuthRequired } from "@utils/app";
-import getUserInterfaceLangId from "@utils/app/user-interface-language";
 import { capitalizeFirstLetter } from "@utils/helpers";
 import { Component } from "inferno";
 import { T } from "inferno-i18next-dess";
@@ -41,8 +40,6 @@ export class CommentForm extends Component<CommentFormProps, any> {
           : undefined
         : undefined;
 
-    const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
-
     return (
       <div
         className={["comment-form", "mb-3", this.props.containerClass].join(
@@ -52,7 +49,6 @@ export class CommentForm extends Component<CommentFormProps, any> {
         {UserService.Instance.myUserInfo ? (
           <MarkdownTextArea
             initialContent={initialContent}
-            initialLanguageId={userInterfaceLangId}
             showLanguage
             buttonTitle={this.buttonTitle}
             finished={this.props.finished}
index 03d868bea7018ee001ed0517b573bc28d9752dc2..c74f24cd6d1a88258ce0e13a3a7a4d62d2f71737 100644 (file)
@@ -49,7 +49,7 @@ export class LanguageSelect extends Component<LanguageSelectProps, any> {
     return this.props.iconVersion ? (
       this.selectBtn
     ) : (
-      <div className="language-select row mb-3">
+      <div className="language-select mb-3">
         <label
           className={classNames(
             "col-form-label",
index 2dd1b84aec58298b80578d6a0a637efc16d54194..f7c4760aaa8da0592f8f3163e0923c328b9d1428 100644 (file)
@@ -274,12 +274,8 @@ export class MarkdownTextArea extends Component<
               <LanguageSelect
                 iconVersion
                 allLanguages={this.props.allLanguages}
-                // Only set the selected language ID if it exists as an option
-                // in the dropdown; otherwise, set it to 0 (Undetermined)
                 selectedLanguageIds={
-                  languageId && this.props.siteLanguages.includes(languageId)
-                    ? [languageId]
-                    : [0]
+                  languageId ? Array.of(languageId) : undefined
                 }
                 siteLanguages={this.props.siteLanguages}
                 onChange={this.handleLanguageChange}
index 84ea77ae86453f2035d2b8627c9bf7dd29a50b66..25a0fcc0889924a62a4b5d740c935859d30885a8 100644 (file)
@@ -4,7 +4,6 @@ import {
   myAuth,
   myAuthRequired,
 } from "@utils/app";
-import getUserInterfaceLangId from "@utils/app/user-interface-language";
 import {
   capitalizeFirstLetter,
   debounce,
@@ -324,9 +323,10 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
   }
 
   render() {
-    const url = this.state.form.url;
+    const firstLang = this.state.form.language_id;
+    const selectedLangs = firstLang ? Array.of(firstLang) : undefined;
 
-    const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
+    const url = this.state.form.url;
 
     return (
       <form className="post-form" onSubmit={linkEvent(this, handlePostSubmit)}>
@@ -494,8 +494,8 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
         </div>
         <LanguageSelect
           allLanguages={this.props.allLanguages}
-          selectedLanguageIds={[userInterfaceLangId]}
           siteLanguages={this.props.siteLanguages}
+          selectedLanguageIds={selectedLangs}
           multiple={false}
           onChange={this.handleLanguageChange}
         />
index 12cf1ea2778eee4934c0f80c1ff42fea79ab1f41..b2b0baac39172055eabc5c40282e6c13d9444510 100644 (file)
@@ -54,7 +54,6 @@ import showScores from "./show-scores";
 import siteBannerCss from "./site-banner-css";
 import updateCommunityBlock from "./update-community-block";
 import updatePersonBlock from "./update-person-block";
-import getUserInterfaceLangId from "./user-interface-language";
 
 export {
   buildCommentsTree,
@@ -90,7 +89,6 @@ export {
   getRecipientIdFromProps,
   getRoleLabelPill,
   getUpdatedSearchId,
-  getUserInterfaceLangId,
   initializeSite,
   insertCommentIntoTree,
   isAuthPath,
diff --git a/src/shared/utils/app/user-interface-language.ts b/src/shared/utils/app/user-interface-language.ts
deleted file mode 100644 (file)
index ff2e439..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Language } from "lemmy-js-client";
-import { I18NextService } from "../../services/I18NextService";
-
-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;
-
-  // Find the Language object with a code that matches the initial characters of
-  // this string
-  const userLang = allLanguages.find(lang => {
-    return i18nLang.indexOf(lang.code) === 0;
-  });
-
-  // Return the ID of that language object, or "0" for Undetermined
-  return userLang?.id || 0;
-}