Dont preselect new post language (#1008)

Lemmy-ui currently preselects the first language in the user
settings when creating a new post or comment. This is a bad
idea because this language might not actually be allowed in
the community. It is better to pass the language as None if
the user didnt specify it explicitly, because then the backend
can smartly choose a language based on the overlap of user
languages and community languages.

This fixes the problem described in
[this thread](https://lemmy.ml/post/1066608), where a user
tries to post in a community that has only English allowed,
with all languages enabled in user settings. In this case
lemmy-ui preselects "undetermined language" as default, which
is not allowed and results in an error. This PR fixes the issue
because it lets the backend automatically select the correct
language (English).
This commit is contained in:
Nutomic 2023-05-13 22:07:05 +02:00 committed by GitHub
parent 2d7c7664ee
commit 1683a745b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 34 deletions

View file

@ -29,7 +29,6 @@ import {
ghostArchiveUrl,
isImage,
myAuth,
myFirstDiscussionLanguageId,
pictrsDeleteToast,
relTags,
setupTippy,
@ -187,13 +186,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
}
render() {
let firstLang =
this.state.form.language_id ??
myFirstDiscussionLanguageId(
this.props.allLanguages,
this.props.siteLanguages,
UserService.Instance.myUserInfo
);
let firstLang = this.state.form.language_id;
let selectedLangs = firstLang ? Array.of(firstLang) : undefined;
let url = this.state.form.url;