From 661a8000cd9488bc94c0a84c6d5491c3a22d7283 Mon Sep 17 00:00:00 2001 From: matc-pub <161147791+matc-pub@users.noreply.github.com> Date: Sat, 8 Jun 2024 17:45:56 +0200 Subject: [PATCH] Handle CrossPostParams when mounting CreatePost (#2521) --- src/shared/components/post/create-post.tsx | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/shared/components/post/create-post.tsx b/src/shared/components/post/create-post.tsx index 01b7c202..4c6073af 100644 --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@ -194,6 +194,18 @@ export class CreatePost extends Component< loading: false, }); } + + const locationState = this.props.history.location.state as + | CrossPostParams + | undefined; + if (locationState) { + this.updateUrl({ + title: locationState.name, + url: locationState.url, + body: locationState.body, + }); + this.setState(s => ({ resetCounter: s.resetCounter + 1 })); + } } } @@ -224,15 +236,10 @@ export class CreatePost extends Component< url, } = this.props; - // Only use the name, url, and body from this - const locationState = this.props.history.location.state as - | CrossPostParams - | undefined; - const params: PostFormParams = { - name: title || locationState?.name, - url: url || locationState?.url, - body: body || locationState?.body, + name: title, + url, + body, community_id: communityId, custom_thumbnail: customThumbnailUrl, language_id: languageId,