From: Dessalines Date: Mon, 29 Apr 2019 16:07:41 +0000 (-0700) Subject: Auto-select current community if creating a post from the community X-Git-Url: http://these/git/%22%7Burl%7D/%7B%60%24%7BghostArchiveUrl%7D/static/%7B%7D/readmes/%7BdonateLemmyUrl%7D?a=commitdiff_plain;h=fe89bc2a42b12d4f483bb3d720c8447de4d97f65;p=lemmy.git Auto-select current community if creating a post from the community page. Fixes #133 --- 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