From 02576f3d597b3c419df20f2a50aa6e587f1d98bb Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 18 May 2016 11:15:17 -0400 Subject: PLT-1909 Fixed error rendering pending posts (#3041) * Fixed error caused by checking if a post is a system message * Fixed trying to edit system posts when using the up arrow hotkey --- webapp/components/post_info.jsx | 2 +- webapp/components/rhs_comment.jsx | 2 +- webapp/components/rhs_root_post.jsx | 2 +- webapp/stores/post_store.jsx | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/webapp/components/post_info.jsx b/webapp/components/post_info.jsx index ed316745f..e4ac39447 100644 --- a/webapp/components/post_info.jsx +++ b/webapp/components/post_info.jsx @@ -33,7 +33,7 @@ export default class PostInfo extends React.Component { var post = this.props.post; var isOwner = this.props.currentUser.id === post.user_id; var isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); - const isSystemMessage = post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX); + const isSystemMessage = post.type && post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX); if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING || Utils.isPostEphemeral(post)) { return ''; diff --git a/webapp/components/rhs_comment.jsx b/webapp/components/rhs_comment.jsx index c4b62efcf..5bd138732 100644 --- a/webapp/components/rhs_comment.jsx +++ b/webapp/components/rhs_comment.jsx @@ -85,7 +85,7 @@ export default class RhsComment extends React.Component { const isOwner = this.props.currentUser.id === post.user_id; var isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); - const isSystemMessage = post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX); + const isSystemMessage = post.type && post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX); var dropdownContents = []; diff --git a/webapp/components/rhs_root_post.jsx b/webapp/components/rhs_root_post.jsx index f82948726..5938d672b 100644 --- a/webapp/components/rhs_root_post.jsx +++ b/webapp/components/rhs_root_post.jsx @@ -41,7 +41,7 @@ export default class RhsRootPost extends React.Component { const user = this.props.user; var isOwner = this.props.currentUser.id === post.user_id; var isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); - const isSystemMessage = post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX); + const isSystemMessage = post.type && post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX); var timestamp = UserStore.getProfile(post.user_id).update_at; var channel = ChannelStore.get(post.channel_id); diff --git a/webapp/stores/post_store.jsx b/webapp/stores/post_store.jsx index 17529acb6..7a532fa2e 100644 --- a/webapp/stores/post_store.jsx +++ b/webapp/stores/post_store.jsx @@ -454,10 +454,11 @@ class PostStoreClass extends EventEmitter { for (let i = 0; i < len; i++) { const post = postList.posts[postList.order[i]]; - // don't edit webhook posts or deleted posts + // don't edit webhook posts, deleted posts, or system messages if (post.user_id !== userId || (post.props && post.props.from_webhook) || - post.state === Constants.POST_DELETED) { + post.state === Constants.POST_DELETED || + (post.type && post.type.startsWith(Constants.SYSTEM_MESSAGE_PREFIX))) { continue; } -- cgit v1.2.3-1-g7c22