From a4267471a57c95dd99e17ee5e9fcc95892970764 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Fri, 13 Nov 2015 12:20:33 -0500
Subject: Converted DeletePostModal to React-Bootstrap

---
 web/react/stores/post_store.jsx | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'web/react/stores/post_store.jsx')

diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx
index 0fe253310..a564a2435 100644
--- a/web/react/stores/post_store.jsx
+++ b/web/react/stores/post_store.jsx
@@ -40,6 +40,7 @@ class PostStoreClass extends EventEmitter {
         this.storePosts = this.storePosts.bind(this);
         this.pStorePosts = this.pStorePosts.bind(this);
         this.getPosts = this.getPosts.bind(this);
+        this.getPost = this.getPost.bind(this);
         this.storePost = this.storePost.bind(this);
         this.pStorePost = this.pStorePost.bind(this);
         this.removePost = this.removePost.bind(this);
@@ -68,6 +69,7 @@ class PostStoreClass extends EventEmitter {
         this.storeLatestUpdate = this.storeLatestUpdate.bind(this);
         this.getLatestUpdate = this.getLatestUpdate.bind(this);
         this.getCurrentUsersLatestPost = this.getCurrentUsersLatestPost.bind(this);
+        this.getCommentCount = this.getCommentCount.bind(this);
     }
     emitChange() {
         this.emit(CHANGE_EVENT);
@@ -193,6 +195,9 @@ class PostStoreClass extends EventEmitter {
     getPosts(channelId) {
         return BrowserStore.getItem('posts_' + channelId);
     }
+    getPost(channelId, postId) {
+        return this.getPosts(channelId).posts[postId];
+    }
     getCurrentUsersLatestPost(channelId, rootId) {
         const userId = UserStore.getCurrentId();
         var postList = makePostListNonNull(this.getPosts(channelId));
@@ -402,6 +407,20 @@ class PostStoreClass extends EventEmitter {
     getLatestUpdate(channelId) {
         return BrowserStore.getItem('latest_post_' + channelId, 0);
     }
+    getCommentCount(post) {
+        const posts = this.getPosts(post.channel_id).posts;
+
+        let commentCount = 0;
+        for (let id in posts) {
+            if (posts.hasOwnProperty(id)) {
+                if (posts[id].root_id === post.id) {
+                    commentCount += 1;
+                }
+            }
+        }
+
+        return commentCount;
+    }
 }
 
 var PostStore = new PostStoreClass();
-- 
cgit v1.2.3-1-g7c22

