Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Deleting the focused post now sends user to normal channel view (#6890)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilander authored and saturninoabril committed Jul 10, 2017
1 parent 7aef85f commit c9b9c69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions actions/post_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
14 changes: 13 additions & 1 deletion reducers/views/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

0 comments on commit c9b9c69

Please sign in to comment.