From 8ce72aedc3a5b4f783fb6ebab38aac8bf5f413ae Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Wed, 31 May 2017 23:55:53 +0800 Subject: fix JS error when adding reaction when latest post is ephemeral (#6512) --- webapp/stores/post_store.jsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'webapp/stores') 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]; -- cgit v1.2.3-1-g7c22