Fix create post for community not having community selected by default

This commit is contained in:
SleeplessOne1917 2023-06-20 20:53:44 -04:00
parent bc658a80a4
commit 6c48cf1822
3 changed files with 6 additions and 6 deletions

@ -1 +1 @@
Subproject commit 7fc71d0860bbe5c6d620ec27112350ffe5b9229c Subproject commit a241fe1255a6363c7ae1ec5a09520c066745e6ce

View file

@ -114,7 +114,7 @@ export class CreatePost extends Component<
if (res.state === "success") { if (res.state === "success") {
this.setState({ this.setState({
selectedCommunityChoice: { selectedCommunityChoice: {
label: res.data.community_view.community.name, label: res.data.community_view.community.title,
value: res.data.community_view.community.id.toString(), value: res.data.community_view.community.id.toString(),
}, },
loading: false, loading: false,

View file

@ -123,16 +123,16 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
...this.state.form, ...this.state.form,
community_id: getIdFromString(selectedCommunityChoice.value), community_id: getIdFromString(selectedCommunityChoice.value),
}, },
communitySearchOptions: [selectedCommunityChoice] communitySearchOptions: [selectedCommunityChoice].concat(
.concat( (
this.props.initialCommunities?.map( this.props.initialCommunities?.map(
({ community: { id, title } }) => ({ ({ community: { id, title } }) => ({
label: title, label: title,
value: id.toString(), value: id.toString(),
}) })
) ?? [] ) ?? []
) ).filter(option => option.value !== selectedCommunityChoice.value)
.filter(option => option.value !== selectedCommunityChoice.value), ),
}; };
} else { } else {
this.state = { this.state = {