From 6c48cf18226516b99c72c2e7115ef368d5ce50ad Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Tue, 20 Jun 2023 20:53:44 -0400 Subject: [PATCH] Fix create post for community not having community selected by default --- lemmy-translations | 2 +- src/shared/components/post/create-post.tsx | 2 +- src/shared/components/post/post-form.tsx | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lemmy-translations b/lemmy-translations index 7fc71d08..a241fe12 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit 7fc71d0860bbe5c6d620ec27112350ffe5b9229c +Subproject commit a241fe1255a6363c7ae1ec5a09520c066745e6ce diff --git a/src/shared/components/post/create-post.tsx b/src/shared/components/post/create-post.tsx index ebdf9995..8c74c341 100644 --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@ -114,7 +114,7 @@ export class CreatePost extends Component< if (res.state === "success") { this.setState({ selectedCommunityChoice: { - label: res.data.community_view.community.name, + label: res.data.community_view.community.title, value: res.data.community_view.community.id.toString(), }, loading: false, diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx index 4b74e07f..7c64c9fe 100644 --- a/src/shared/components/post/post-form.tsx +++ b/src/shared/components/post/post-form.tsx @@ -123,16 +123,16 @@ export class PostForm extends Component { ...this.state.form, community_id: getIdFromString(selectedCommunityChoice.value), }, - communitySearchOptions: [selectedCommunityChoice] - .concat( + communitySearchOptions: [selectedCommunityChoice].concat( + ( this.props.initialCommunities?.map( ({ community: { id, title } }) => ({ label: title, value: id.toString(), }) ) ?? [] - ) - .filter(option => option.value !== selectedCommunityChoice.value), + ).filter(option => option.value !== selectedCommunityChoice.value) + ), }; } else { this.state = {