]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/components/post/create-post.tsx
Merge branch 'main' into route-data-refactor
[lemmy-ui.git] / src / shared / components / post / create-post.tsx
index a0e439bb8b842c852025cc68631510810cf863f8..046bc2de5e2c4dd0eeaccf15ae2388ffbde6c55c 100644 (file)
@@ -35,7 +35,7 @@ export interface CreatePostProps {
 }
 
 type CreatePostData = RouteDataResponse<{
-  communityResponse?: GetCommunityResponse;
+  communityResponse: GetCommunityResponse;
   initialCommunitiesRes: ListCommunitiesResponse;
 }>;
 
@@ -232,6 +232,10 @@ export class CreatePost extends Component<
     if (res.state === "success") {
       const postId = res.data.post_view.post.id;
       this.props.history.replace(`/post/${postId}`);
+    } else {
+      this.setState({
+        loading: false,
+      });
     }
   }
 
@@ -244,6 +248,7 @@ export class CreatePost extends Component<
   >): Promise<CreatePostData> {
     const data: CreatePostData = {
       initialCommunitiesRes: await fetchCommunitiesForOptions(client),
+      communityResponse: { state: "empty" },
     };
 
     if (communityId) {