diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-06-28 02:59:08 +0800 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-06-27 14:59:08 -0400 |
commit | 0b62078712190be9edaf8428762185f1c38d5226 (patch) | |
tree | 933d4b779723483501cb6ee09193f41f10fc8e63 | |
parent | e2daa425fac3c976e21ed048b13424a2dc437a20 (diff) | |
download | chat-0b62078712190be9edaf8428762185f1c38d5226.tar.gz chat-0b62078712190be9edaf8428762185f1c38d5226.tar.bz2 chat-0b62078712190be9edaf8428762185f1c38d5226.zip |
[PLT-6745] Fix action of SHIFT+UP by fixing latest replay-able post (#6738)
* fix latest replayable post
* use PostUtils.isSystemMessage instead of checkin that post.type is empty
-rw-r--r-- | webapp/components/create_post.jsx | 6 | ||||
-rw-r--r-- | webapp/stores/post_store.jsx | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx index 124728c3d..d0f2a0afd 100644 --- a/webapp/components/create_post.jsx +++ b/webapp/components/create_post.jsx @@ -496,9 +496,9 @@ export default class CreatePost extends React.Component { return; } - const latestNonEphemeralPost = PostStore.getLatestNonEphemeralPost(this.state.channelId); - const latestNonEphemeralPostId = latestNonEphemeralPost == null ? '' : latestNonEphemeralPost.id; - const lastPostEl = document.getElementById(`commentIcon_${this.state.channelId}_${latestNonEphemeralPostId}`); + const latestReplyablePost = PostStore.getLatestReplyablePost(this.state.channelId); + const latestReplyablePostId = latestReplyablePost == null ? '' : latestReplyablePost.id; + const lastPostEl = document.getElementById(`commentIcon_${this.state.channelId}_${latestReplyablePostId}`); if (!e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && e.keyCode === KeyCodes.UP && this.state.message === '') { e.preventDefault(); diff --git a/webapp/stores/post_store.jsx b/webapp/stores/post_store.jsx index 66e7108ca..b4c8c43c8 100644 --- a/webapp/stores/post_store.jsx +++ b/webapp/stores/post_store.jsx @@ -8,6 +8,7 @@ import ChannelStore from 'stores/channel_store.jsx'; import BrowserStore from 'stores/browser_store.jsx'; import UserStore from 'stores/user_store.jsx'; +import * as PostUtils from 'utils/post_utils.jsx'; import {Constants} from 'utils/constants.jsx'; const ActionTypes = Constants.ActionTypes; @@ -69,13 +70,13 @@ class PostStoreClass extends EventEmitter { return postsInChannel[0]; } - getLatestNonEphemeralPost(channelId) { + getLatestReplyablePost(channelId) { const postIds = getState().entities.posts.postsInChannel[channelId]; const posts = getState().entities.posts.posts; for (const postId of postIds) { const post = posts[postId] || {}; - if (post.state !== Constants.POST_DELETED && post.type !== Constants.PostTypes.EPHEMERAL) { + if (post.state !== Constants.POST_DELETED && !PostUtils.isSystemMessage(post)) { return post; } } |