From fe89bc2a42b12d4f483bb3d720c8447de4d97f65 Mon Sep 17 00:00:00 2001
From: Dessalines <tyhou13@gmx.com>
Date: Mon, 29 Apr 2019 09:07:41 -0700
Subject: Auto-select current community if creating a post from the community
 page.

Fixes #133
---
 ui/src/components/navbar.tsx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'ui/src/components/navbar.tsx')

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<any, NavbarState> {
               <Link class="nav-link" to="/search">Search</Link>
             </li>
             <li class="nav-item">
-              <Link class="nav-link" to="/create_post">Create Post</Link>
+              <Link class="nav-link" to={{pathname: '/create_post', state: { prevPath: this.currentLocation }}}>Create Post</Link>
             </li>
             <li class="nav-item">
               <Link class="nav-link" to="/create_community">Create Community</Link>
@@ -165,6 +165,10 @@ export class Navbar extends Component<any, NavbarState> {
     }
   }
 
+  get currentLocation() {
+    return this.context.router.history.location.pathname;
+  }
+
   sendRepliesCount(res: GetRepliesResponse) {
     UserService.Instance.sub.next({user: UserService.Instance.user, unreadCount: res.replies.filter(r => !r.read).length});
   }
-- 
cgit v1.2.3

