import { myAuthRequired } from "@utils/app";
+import getUserPrimaryLanguage from "@utils/app/user-primary-language";
import { capitalizeFirstLetter } from "@utils/helpers";
import { Component } from "inferno";
import { T } from "inferno-i18next-dess";
: undefined
: undefined;
+ const userPrimaryLanguage = getUserPrimaryLanguage(
+ UserService?.Instance?.myUserInfo
+ );
+
return (
<div
className={["comment-form", "mb-3", this.props.containerClass].join(
{UserService.Instance.myUserInfo ? (
<MarkdownTextArea
initialContent={initialContent}
+ initialLanguageId={userPrimaryLanguage}
showLanguage
buttonTitle={this.buttonTitle}
finished={this.props.finished}
myAuth,
myAuthRequired,
} from "@utils/app";
+import getUserPrimaryLanguage from "@utils/app/user-primary-language";
import {
capitalizeFirstLetter,
debounce,
}
render() {
- const firstLang = this.state.form.language_id;
- const selectedLangs = firstLang ? Array.of(firstLang) : undefined;
+ const userPrimaryLanguage = getUserPrimaryLanguage(
+ UserService?.Instance?.myUserInfo
+ );
const url = this.state.form.url;
</div>
<LanguageSelect
allLanguages={this.props.allLanguages}
+ selectedLanguageIds={[userPrimaryLanguage]}
siteLanguages={this.props.siteLanguages}
- selectedLanguageIds={selectedLangs}
multiple={false}
onChange={this.handleLanguageChange}
/>
import siteBannerCss from "./site-banner-css";
import updateCommunityBlock from "./update-community-block";
import updatePersonBlock from "./update-person-block";
+import getUserPrimaryLanguage from "./user-primary-language";
export {
buildCommentsTree,
getIdFromProps,
getRecipientIdFromProps,
getUpdatedSearchId,
+ getUserPrimaryLanguage,
initializeSite,
insertCommentIntoTree,
isAuthPath,
--- /dev/null
+import { UserService } from "../../services";
+
+export default function getUserPrimaryLanguage(
+ myUserInfo = UserService.Instance.myUserInfo
+): number {
+ // Get first language in discussion languages array that isn't equal to "0",
+ // which is the language selection "Undetermined"
+ return myUserInfo?.discussion_languages.find(lang => lang !== 0) || 0;
+}