From d9eb29a7248fd04610f8872d91829b2954b87938 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 4 Jul 2018 08:44:33 -0400 Subject: [PATCH] MM-10826 Show error when viewing permalink for locally deleted post (#1870) * MM-10826 Show error when viewing permalink for locally deleted post * Don't hide current user's deleted posts --- app/screens/permalink/index.js | 9 ++++++--- app/selectors/post_list.js | 4 ---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/screens/permalink/index.js b/app/screens/permalink/index.js index 9b34d1af7..7480e13da 100644 --- a/app/screens/permalink/index.js +++ b/app/screens/permalink/index.js @@ -6,6 +6,7 @@ import {connect} from 'react-redux'; import {getChannel as getChannelAction, joinChannel, markChannelAsRead, markChannelAsViewed} from 'mattermost-redux/actions/channels'; import {getPostsAfter, getPostsBefore, getPostThread, selectPost} from 'mattermost-redux/actions/posts'; +import {Posts} from 'mattermost-redux/constants'; import {makeGetChannel, getMyChannelMemberships} from 'mattermost-redux/selectors/entities/channels'; import {makeGetPostIdsAroundPost, getPost} from 'mattermost-redux/selectors/entities/posts'; import {getTheme} from 'mattermost-redux/selectors/entities/preferences'; @@ -29,11 +30,13 @@ function makeMapStateToProps() { return function mapStateToProps(state) { const {currentFocusedPostId} = state.entities.posts; const post = getPost(state, currentFocusedPostId); - const channel = post ? getChannel(state, {id: post.channel_id}) : null; + + let channel; let postIds; - if (channel && channel.id) { - postIds = getPostIdsAroundPost(state, currentFocusedPostId, channel.id, { + if (post && post.delete_at === 0 && post.state !== Posts.POST_DELETED) { + channel = getChannel(state, {id: post.channel_id}); + postIds = getPostIdsAroundPost(state, currentFocusedPostId, post.channel_id, { postsBeforeCount: 10, postsAfterCount: 10, }); diff --git a/app/selectors/post_list.js b/app/selectors/post_list.js index dd53aab91..b138aa6f8 100644 --- a/app/selectors/post_list.js +++ b/app/selectors/post_list.js @@ -47,10 +47,6 @@ export function makePreparePostIdsForPostList() { continue; } - if (post.state === Posts.POST_DELETED && post.user_id === currentUser.id) { - continue; - } - // Filter out join/leave messages if necessary if (shouldFilterJoinLeavePost(post, showJoinLeave, currentUser.username)) { continue;