summaryrefslogtreecommitdiffstats
path: root/webapp/stores/post_store.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/stores/post_store.jsx')
-rw-r--r--webapp/stores/post_store.jsx21
1 files changed, 18 insertions, 3 deletions
diff --git a/webapp/stores/post_store.jsx b/webapp/stores/post_store.jsx
index fbe5cd457..5e8155c40 100644
--- a/webapp/stores/post_store.jsx
+++ b/webapp/stores/post_store.jsx
@@ -118,7 +118,15 @@ class PostStoreClass extends EventEmitter {
getEarliestPost(id) {
if (this.postsInfo.hasOwnProperty(id)) {
- return this.postsInfo[id].postList.posts[this.postsInfo[id].postList.order[this.postsInfo[id].postList.order.length - 1]];
+ const postList = this.postsInfo[id].postList;
+
+ for (let i = postList.order.length - 1; i >= 0; i--) {
+ const postId = postList.order[i];
+
+ if (postList.posts[postId].state !== Constants.POST_DELETED) {
+ return postList.posts[postId];
+ }
+ }
}
return null;
@@ -126,7 +134,13 @@ class PostStoreClass extends EventEmitter {
getLatestPost(id) {
if (this.postsInfo.hasOwnProperty(id)) {
- return this.postsInfo[id].postList.posts[this.postsInfo[id].postList.order[0]];
+ const postList = this.postsInfo[id].postList;
+
+ for (const postId of postList.order) {
+ if (postList.posts[postId].state !== Constants.POST_DELETED) {
+ return postList.posts[postId];
+ }
+ }
}
return null;
@@ -318,7 +332,8 @@ class PostStoreClass extends EventEmitter {
// make sure to copy the post so that component state changes work properly
postList.posts[post.id] = Object.assign({}, post, {
state: Constants.POST_DELETED,
- file_ids: []
+ file_ids: [],
+ has_reactions: false
});
}
}