1 import { Component } from 'inferno';
2 import { PostForm } from './post-form';
4 export class CreatePost extends Component<any, any> {
6 constructor(props: any, context: any) {
8 this.handlePostCreate = this.handlePostCreate.bind(this);
12 document.title = "Create Post - Lemmy";
17 <div class="container">
19 <div class="col-12 col-lg-6 mb-4">
20 <h5>Create a Post</h5>
21 <PostForm onCreate={this.handlePostCreate} prevCommunityName={this.prevCommunityName} />
28 get prevCommunityName(): string {
29 if (this.props.match.params.name) {
30 return this.props.match.params.name;
31 } else if (this.props.location.state) {
32 let lastLocation = this.props.location.state.prevPath;
33 if (lastLocation.includes("/c/")) {
34 return lastLocation.split("/c/")[1];
40 handlePostCreate(id: number) {
41 this.props.history.push(`/post/${id}`);