mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-01 10:09:56 +00:00
fix: Fix language selection bug
This commit is contained in:
parent
bf54d40433
commit
ccf0a6dbaa
4 changed files with 18 additions and 10 deletions
|
@ -41,7 +41,9 @@ export class CommentForm extends Component<CommentFormProps, any> {
|
|||
: undefined
|
||||
: undefined;
|
||||
|
||||
const userInterfaceLangId = getUserInterfaceLangId({
|
||||
const userInterfaceLangId = !UserService.Instance.myUserInfo
|
||||
? 0
|
||||
: getUserInterfaceLangId({
|
||||
myUserInfo: UserService.Instance.myUserInfo,
|
||||
allLanguages: this.props.allLanguages,
|
||||
});
|
||||
|
|
|
@ -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,7 +326,9 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||
render() {
|
||||
const url = this.state.form.url;
|
||||
|
||||
const userInterfaceLangId = getUserInterfaceLangId({
|
||||
const userInterfaceLangId = !UserService.Instance.myUserInfo
|
||||
? 0
|
||||
: getUserInterfaceLangId({
|
||||
myUserInfo: UserService.Instance.myUserInfo,
|
||||
allLanguages: this.props.allLanguages,
|
||||
});
|
||||
|
|
|
@ -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