From 3da238bd8ccbe07a17770cf3b06aa2a02f1ffd7b Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 11 May 2023 21:44:30 +0200 Subject: [PATCH] Dont preselect new post language 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). --- lemmy-translations | 2 +- src/shared/components/comment/comment-form.tsx | 11 ----------- src/shared/components/common/language-select.tsx | 5 +++++ src/shared/components/post/post-form.tsx | 9 +-------- src/shared/utils.ts | 14 -------------- 5 files changed, 7 insertions(+), 34 deletions(-) diff --git a/lemmy-translations b/lemmy-translations index 007e5368..a1fff8b4 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit 007e53683768aeba63e9e4c179c1d240217bcee2 +Subproject commit a1fff8b481f4b02327e4ee04088606af627628f2 diff --git a/src/shared/components/comment/comment-form.tsx b/src/shared/components/comment/comment-form.tsx index c7285193..74d17bff 100644 --- a/src/shared/components/comment/comment-form.tsx +++ b/src/shared/components/comment/comment-form.tsx @@ -17,7 +17,6 @@ import { UserService, WebSocketService } from "../../services"; import { capitalizeFirstLetter, myAuth, - myFirstDiscussionLanguageId, wsClient, wsSubscribe, } from "../../utils"; @@ -77,21 +76,11 @@ export class CommentForm extends Component { : undefined : undefined; - let selectedLang = - typeof this.props.node !== "number" - ? this.props.node.comment_view.comment.language_id - : myFirstDiscussionLanguageId( - this.props.allLanguages, - this.props.siteLanguages, - UserService.Instance.myUserInfo - ); - return (
{UserService.Instance.myUserInfo ? ( { multiple={this.props.multiple} disabled={this.props.disabled} > + {!this.props.multiple && ( + + )} {filteredLangs.map(l => (