summaryrefslogtreecommitdiffstats
path: root/ui/src/components/create-post.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-04-29 09:07:41 -0700
committerDessalines <tyhou13@gmx.com>2019-04-29 09:07:41 -0700
commitfe89bc2a42b12d4f483bb3d720c8447de4d97f65 (patch)
treee4ed8480c6bc490e847e1f2a6d0282ea8958fc3f /ui/src/components/create-post.tsx
parent50dfcefc9564baa896de8b3f1efbcc61de7054f3 (diff)
Auto-select current community if creating a post from the community
page. Fixes #133
Diffstat (limited to 'ui/src/components/create-post.tsx')
-rw-r--r--ui/src/components/create-post.tsx12
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}`);
}