summaryrefslogtreecommitdiffstats
path: root/web/react/stores
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-11-18 09:07:57 -0500
committerChristopher Speller <crspeller@gmail.com>2015-11-18 09:07:57 -0500
commit9660adb00775aba822d2d684d215c55679a456c6 (patch)
tree0db5c19e03609cbce3f70e20c7fe45a10f640d18 /web/react/stores
parent7b01528d17c61a762ded17a23ccd9a2a728910a0 (diff)
parenta4267471a57c95dd99e17ee5e9fcc95892970764 (diff)
downloadchat-9660adb00775aba822d2d684d215c55679a456c6.tar.gz
chat-9660adb00775aba822d2d684d215c55679a456c6.tar.bz2
chat-9660adb00775aba822d2d684d215c55679a456c6.zip
Merge pull request #1430 from hmhealey/plt737a
PLT-737 Converted DeletePostModal to React-Bootstrap
Diffstat (limited to 'web/react/stores')
-rw-r--r--web/react/stores/modal_store.jsx8
-rw-r--r--web/react/stores/post_store.jsx19
2 files changed, 24 insertions, 3 deletions
diff --git a/web/react/stores/modal_store.jsx b/web/react/stores/modal_store.jsx
index dc65d48da..809f83a59 100644
--- a/web/react/stores/modal_store.jsx
+++ b/web/react/stores/modal_store.jsx
@@ -27,12 +27,14 @@ class ModalStoreClass extends EventEmitter {
}
handleEventPayload(payload) {
- const action = payload.action;
+ // toggle event handlers should accept a boolean show/hide value and can accept a map of arguments
+ const {type, value, ...args} = payload.action;
- switch (action.type) {
+ switch (type) {
case ActionTypes.TOGGLE_IMPORT_THEME_MODAL:
case ActionTypes.TOGGLE_INVITE_MEMBER_MODAL:
- this.emit(action.type, action.value);
+ case ActionTypes.TOGGLE_DELETE_POST_MODAL:
+ this.emit(type, value, args);
break;
}
}
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();