diff options
Diffstat (limited to 'ui/src/components/create-post.tsx')
-rw-r--r-- | ui/src/components/create-post.tsx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ui/src/components/create-post.tsx b/ui/src/components/create-post.tsx index e2998ca7..1958be72 100644 --- a/ui/src/components/create-post.tsx +++ b/ui/src/components/create-post.tsx @@ -18,13 +18,23 @@ export class CreatePost extends Component<any, any> { <div class="row"> <div class="col-12 col-lg-6 mb-4"> <h5>Create a Post</h5> - <PostForm onCreate={this.handlePostCreate}/> + <PostForm onCreate={this.handlePostCreate} prevCommunityName={this.prevCommunityName} /> </div> </div> </div> ) } + get prevCommunityName(): string { + if (this.props.location.state) { + let lastLocation = this.props.location.state.prevPath; + if (lastLocation.includes("/c/")) { + return lastLocation.split("/c/")[1]; + } + } + return undefined; + } + handlePostCreate(id: number) { this.props.history.push(`/post/${id}`); } |