mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-01 10:09:56 +00:00
Merge pull request #1667 from jsit/fix/revert-lang-auto-select
Revert #1463, markdown default lang select
This commit is contained in:
commit
98fc8af062
6 changed files with 6 additions and 34 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
import { myAuthRequired } from "@utils/app";
|
||||||
import getUserInterfaceLangId from "@utils/app/user-interface-language";
|
|
||||||
import { capitalizeFirstLetter } from "@utils/helpers";
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
import { T } from "inferno-i18next-dess";
|
import { T } from "inferno-i18next-dess";
|
||||||
|
@ -41,8 +40,6 @@ export class CommentForm extends Component<CommentFormProps, any> {
|
||||||
: undefined
|
: undefined
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={["comment-form", "mb-3", this.props.containerClass].join(
|
className={["comment-form", "mb-3", this.props.containerClass].join(
|
||||||
|
@ -52,7 +49,6 @@ export class CommentForm extends Component<CommentFormProps, any> {
|
||||||
{UserService.Instance.myUserInfo ? (
|
{UserService.Instance.myUserInfo ? (
|
||||||
<MarkdownTextArea
|
<MarkdownTextArea
|
||||||
initialContent={initialContent}
|
initialContent={initialContent}
|
||||||
initialLanguageId={userInterfaceLangId}
|
|
||||||
showLanguage
|
showLanguage
|
||||||
buttonTitle={this.buttonTitle}
|
buttonTitle={this.buttonTitle}
|
||||||
finished={this.props.finished}
|
finished={this.props.finished}
|
||||||
|
|
|
@ -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 row mb-3">
|
<div className="language-select mb-3">
|
||||||
<label
|
<label
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"col-form-label",
|
"col-form-label",
|
||||||
|
|
|
@ -274,12 +274,8 @@ export class MarkdownTextArea extends Component<
|
||||||
<LanguageSelect
|
<LanguageSelect
|
||||||
iconVersion
|
iconVersion
|
||||||
allLanguages={this.props.allLanguages}
|
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={
|
selectedLanguageIds={
|
||||||
languageId && this.props.siteLanguages.includes(languageId)
|
languageId ? Array.of(languageId) : undefined
|
||||||
? [languageId]
|
|
||||||
: [0]
|
|
||||||
}
|
}
|
||||||
siteLanguages={this.props.siteLanguages}
|
siteLanguages={this.props.siteLanguages}
|
||||||
onChange={this.handleLanguageChange}
|
onChange={this.handleLanguageChange}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
myAuth,
|
myAuth,
|
||||||
myAuthRequired,
|
myAuthRequired,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import getUserInterfaceLangId from "@utils/app/user-interface-language";
|
|
||||||
import {
|
import {
|
||||||
capitalizeFirstLetter,
|
capitalizeFirstLetter,
|
||||||
debounce,
|
debounce,
|
||||||
|
@ -324,9 +323,10 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
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 (
|
return (
|
||||||
<form className="post-form" onSubmit={linkEvent(this, handlePostSubmit)}>
|
<form className="post-form" onSubmit={linkEvent(this, handlePostSubmit)}>
|
||||||
|
@ -494,8 +494,8 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
</div>
|
</div>
|
||||||
<LanguageSelect
|
<LanguageSelect
|
||||||
allLanguages={this.props.allLanguages}
|
allLanguages={this.props.allLanguages}
|
||||||
selectedLanguageIds={[userInterfaceLangId]}
|
|
||||||
siteLanguages={this.props.siteLanguages}
|
siteLanguages={this.props.siteLanguages}
|
||||||
|
selectedLanguageIds={selectedLangs}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
onChange={this.handleLanguageChange}
|
onChange={this.handleLanguageChange}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -54,7 +54,6 @@ import showScores from "./show-scores";
|
||||||
import siteBannerCss from "./site-banner-css";
|
import siteBannerCss from "./site-banner-css";
|
||||||
import updateCommunityBlock from "./update-community-block";
|
import updateCommunityBlock from "./update-community-block";
|
||||||
import updatePersonBlock from "./update-person-block";
|
import updatePersonBlock from "./update-person-block";
|
||||||
import getUserInterfaceLangId from "./user-interface-language";
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
buildCommentsTree,
|
buildCommentsTree,
|
||||||
|
@ -90,7 +89,6 @@ export {
|
||||||
getRecipientIdFromProps,
|
getRecipientIdFromProps,
|
||||||
getRoleLabelPill,
|
getRoleLabelPill,
|
||||||
getUpdatedSearchId,
|
getUpdatedSearchId,
|
||||||
getUserInterfaceLangId,
|
|
||||||
initializeSite,
|
initializeSite,
|
||||||
insertCommentIntoTree,
|
insertCommentIntoTree,
|
||||||
isAuthPath,
|
isAuthPath,
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
Loading…
Reference in a new issue