summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-07-10 14:51:31 -0400
committerSaturnino Abril <saturnino.abril@gmail.com>2017-07-11 02:51:31 +0800
commit1e7022ff6d04b5f341c13530105d9dcf08c88ca8 (patch)
treea6abe16653ca436bd5eed353398d7222fabb0d19 /webapp
parentf1cf1b5f7a3b4eba032dd673899a3c1ca7e57ef0 (diff)
downloadchat-1e7022ff6d04b5f341c13530105d9dcf08c88ca8.tar.gz
chat-1e7022ff6d04b5f341c13530105d9dcf08c88ca8.tar.bz2
chat-1e7022ff6d04b5f341c13530105d9dcf08c88ca8.zip
Deleting the focused post now sends user to normal channel view (#6890)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/actions/post_actions.jsx8
-rw-r--r--webapp/reducers/views/channel.js14
2 files changed, 21 insertions, 1 deletions
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();
}
diff --git a/webapp/reducers/views/channel.js b/webapp/reducers/views/channel.js
index 0deb2389e..1da6c2e29 100644
--- a/webapp/reducers/views/channel.js
+++ b/webapp/reducers/views/channel.js
@@ -62,8 +62,20 @@ function loadingPosts(state = {}, action) {
}
}
+function focusedPostId(state = '', action) {
+ switch (action.type) {
+ case ActionTypes.RECEIVED_FOCUSED_POST:
+ return action.data;
+ case ChannelTypes.SELECT_CHANNEL:
+ return '';
+ default:
+ return state;
+ }
+}
+
export default combineReducers({
postVisibility,
lastChannelViewTime,
- loadingPosts
+ loadingPosts,
+ focusedPostId
});