}
type CreatePostData = RouteDataResponse<{
- communityResponse?: GetCommunityResponse;
+ communityResponse: GetCommunityResponse;
initialCommunitiesRes: ListCommunitiesResponse;
}>;
const { communityResponse: communityRes, initialCommunitiesRes } =
this.isoData.routeData;
+ this.state = {
+ ...this.state,
+ loading: false,
+ initialCommunitiesRes,
+ isIsomorphic: true,
+ };
+
if (communityRes?.state === "success") {
const communityChoice: Choice = {
label: communityRes.data.community_view.community.title,
selectedCommunityChoice: communityChoice,
};
}
-
- this.state = {
- ...this.state,
- loading: false,
- initialCommunitiesRes,
- isIsomorphic: true,
- };
}
}
if (res.state === "success") {
const postId = res.data.post_view.post.id;
this.props.history.replace(`/post/${postId}`);
+ } else {
+ this.setState({
+ loading: false,
+ });
}
}
>): Promise<CreatePostData> {
const data: CreatePostData = {
initialCommunitiesRes: await fetchCommunitiesForOptions(client),
+ communityResponse: { state: "empty" },
};
if (communityId) {