Handle CrossPostParams when mounting CreatePost (#2521)

This commit is contained in:
matc-pub 2024-06-08 17:45:56 +02:00 committed by GitHub
parent 761cd7aa4e
commit 661a8000cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -194,6 +194,18 @@ export class CreatePost extends Component<
loading: false, 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, url,
} = this.props; } = this.props;
// Only use the name, url, and body from this
const locationState = this.props.history.location.state as
| CrossPostParams
| undefined;
const params: PostFormParams = { const params: PostFormParams = {
name: title || locationState?.name, name: title,
url: url || locationState?.url, url,
body: body || locationState?.body, body,
community_id: communityId, community_id: communityId,
custom_thumbnail: customThumbnailUrl, custom_thumbnail: customThumbnailUrl,
language_id: languageId, language_id: languageId,