From 1e7022ff6d04b5f341c13530105d9dcf08c88ca8 Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Mon, 10 Jul 2017 14:51:31 -0400
Subject: Deleting the focused post now sends user to normal channel view
 (#6890)

---
 webapp/actions/post_actions.jsx | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'webapp/actions/post_actions.jsx')

diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx
index 43204a543..87d9ed739 100644
--- a/webapp/actions/post_actions.jsx
+++ b/webapp/actions/post_actions.jsx
@@ -14,6 +14,8 @@ import {sendDesktopNotification} from 'actions/notification_actions.jsx';
 import Constants from 'utils/constants.jsx';
 const ActionTypes = Constants.ActionTypes;
 
+import {browserHistory} from 'react-router/es6';
+
 // Redux actions
 import store from 'stores/redux_store.jsx';
 const dispatch = store.dispatch;
@@ -236,6 +238,12 @@ export function deletePost(channelId, post, success) {
                 data: post
             });
 
+            const {focusedPostId} = getState().views.channel;
+            const channel = getState().entities.channels.channels[post.channel_id];
+            if (post.id === focusedPostId && channel) {
+                browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + channel.name);
+            }
+
             if (success) {
                 success();
             }
-- 
cgit v1.2.3-1-g7c22

