diff options
-rw-r--r-- | webapp/components/create_post.jsx | 6 | ||||
-rw-r--r-- | webapp/stores/post_store.jsx | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx index dab1d9735..22fba0e73 100644 --- a/webapp/components/create_post.jsx +++ b/webapp/components/create_post.jsx @@ -270,11 +270,11 @@ export default class CreatePost extends React.Component { const action = isReaction[1]; const emojiName = isReaction[2]; - const postId = PostStore.getLatestPost(this.state.channelId).id; + const postId = PostStore.getLatestNonEphemeralPost(this.state.channelId).id; - if (action === '+') { + if (postId && action === '+') { PostActions.addReaction(this.state.channelId, postId, emojiName); - } else if (action === '-') { + } else if (postId && action === '-') { PostActions.removeReaction(this.state.channelId, postId, emojiName); } diff --git a/webapp/stores/post_store.jsx b/webapp/stores/post_store.jsx index 770e232ca..a402490af 100644 --- a/webapp/stores/post_store.jsx +++ b/webapp/stores/post_store.jsx @@ -148,6 +148,20 @@ class PostStoreClass extends EventEmitter { return null; } + getLatestNonEphemeralPost(id) { + if (this.postsInfo.hasOwnProperty(id)) { + const postList = this.postsInfo[id].postList; + + for (const postId of postList.order) { + if (postList.posts[postId].state !== Constants.POST_DELETED && postList.posts[postId].type !== Constants.PostTypes.EPHEMERAL) { + return postList.posts[postId]; + } + } + } + + return null; + } + getLatestPostFromPageTime(id) { if (this.latestPageTime.hasOwnProperty(id)) { return this.latestPageTime[id]; |