mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-08 17:44:16 +00:00
fix: Fix language selection bug
This commit is contained in:
parent
bf54d40433
commit
ccf0a6dbaa
|
@ -41,10 +41,12 @@ export class CommentForm extends Component<CommentFormProps, any> {
|
|||
: undefined
|
||||
: undefined;
|
||||
|
||||
const userInterfaceLangId = getUserInterfaceLangId({
|
||||
myUserInfo: UserService.Instance.myUserInfo,
|
||||
allLanguages: this.props.allLanguages,
|
||||
});
|
||||
const userInterfaceLangId = !UserService.Instance.myUserInfo
|
||||
? 0
|
||||
: getUserInterfaceLangId({
|
||||
myUserInfo: UserService.Instance.myUserInfo,
|
||||
allLanguages: this.props.allLanguages,
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
@ -260,8 +260,12 @@ 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 ? Array.of(languageId) : undefined
|
||||
languageId && this.props.siteLanguages.includes(languageId)
|
||||
? Array.of(languageId)
|
||||
: [0]
|
||||
}
|
||||
siteLanguages={this.props.siteLanguages}
|
||||
onChange={this.handleLanguageChange}
|
||||
|
|
|
@ -326,10 +326,12 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||
render() {
|
||||
const url = this.state.form.url;
|
||||
|
||||
const userInterfaceLangId = getUserInterfaceLangId({
|
||||
myUserInfo: UserService.Instance.myUserInfo,
|
||||
allLanguages: this.props.allLanguages,
|
||||
});
|
||||
const userInterfaceLangId = !UserService.Instance.myUserInfo
|
||||
? 0
|
||||
: getUserInterfaceLangId({
|
||||
myUserInfo: UserService.Instance.myUserInfo,
|
||||
allLanguages: this.props.allLanguages,
|
||||
});
|
||||
|
||||
return (
|
||||
<form className="post-form" onSubmit={linkEvent(this, handlePostSubmit)}>
|
||||
|
|
|
@ -17,6 +17,6 @@ export default function getUserInterfaceLanguageId({
|
|||
return i18nLang.indexOf(lang.code) === 0;
|
||||
});
|
||||
|
||||
// Return the ID of that language object
|
||||
// Return the ID of that language object, or "0" for Undetermined
|
||||
return userLang.id || 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue