From fe89bc2a42b12d4f483bb3d720c8447de4d97f65 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 29 Apr 2019 09:07:41 -0700 Subject: [PATCH 1/3] Auto-select current community if creating a post from the community page. Fixes #133 --- ui/src/components/create-post.tsx | 12 +++++++++++- ui/src/components/navbar.tsx | 6 +++++- ui/src/components/post-form.tsx | 4 ++++ 3 files changed, 20 insertions(+), 2 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 {
Create a Post
- +
) } + 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}`); } diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx index 31dab61b..ee19e5c5 100644 --- a/ui/src/components/navbar.tsx +++ b/ui/src/components/navbar.tsx @@ -79,7 +79,7 @@ export class Navbar extends Component { Search