diff --git a/client/coral-framework/store/reducers/items.js b/client/coral-framework/store/reducers/items.js index e8f0bbbdf..2bba3bf1b 100644 --- a/client/coral-framework/store/reducers/items.js +++ b/client/coral-framework/store/reducers/items.js @@ -8,18 +8,13 @@ const initialState = fromJS({}) export default (state = initialState, action) => { switch (action.type) { case actions.ADD_ITEM: - return state.set(action.item_id, fromJS(action.item)) + return state.set(action.id, fromJS(action.item)) case actions.UPDATE_ITEM: - return state.updateIn([action.item_id, 'data', action.property], () => + return state.updateIn([action.id, action.property], () => fromJS(action.value) ) case actions.APPEND_ITEM_ARRAY: - return state.updateIn([action.item_id, 'data', action.property], (prop) => { - return prop ? prop.push(action.value) : fromJS([action.value]) - } - ) - case actions.APPEND_ITEM_RELATED: - return state.updateIn([action.item_id, 'related', action.property], (prop) => { + return state.updateIn([action.id, action.property], (prop) => { return prop ? prop.push(action.value) : fromJS([action.value]) } ) diff --git a/client/coral-plugin-comment-count/CommentCount.js b/client/coral-plugin-comment-count/CommentCount.js index 861fc5df3..6c3b2e5eb 100644 --- a/client/coral-plugin-comment-count/CommentCount.js +++ b/client/coral-plugin-comment-count/CommentCount.js @@ -2,16 +2,16 @@ import React from 'react' const name = 'coral-plugin-comment-count' -const CommentCount = ({items, item_id}) => { +const CommentCount = ({items, id}) => { let count = 0 - if (items[item_id]) { - count += items[item_id].related.comment.length + if (items[id]) { + count += items[id].comments.length } const itemKeys = Object.keys(items) for (var i=0; i < itemKeys.length; i++) { const item = items[itemKeys[i]] - if (item.type === 'comment' && item.related && item.related.child) { - count += item.related.child.length + if (item.type === 'comment' && item.children) { + count += item.children.length } } diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index a32144407..f20ced54c 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -18,7 +18,7 @@ class CommentBox extends Component { } postComment = () => { - const {postItem, updateItem, item_id, reply, addNotification, appendItemRelated} = this.props + const {postItem, updateItem, item_id, reply, addNotification, appendItemArray} = this.props let comment = { content: this.state.content } @@ -33,7 +33,7 @@ class CommentBox extends Component { updateItem(item_id, 'showReply', false) postItem(comment, 'comment') .then((id) => { - appendItemRelated(item_id, related, id) + appendItemArray(item_id, related, id) addNotification('success', 'Your comment has been posted.') }).catch((err) => console.error(err)) this.setState({content: ''}) diff --git a/client/coral-plugin-replies/ReplyBox.js b/client/coral-plugin-replies/ReplyBox.js index 7a89bdeeb..d496a63f7 100644 --- a/client/coral-plugin-replies/ReplyBox.js +++ b/client/coral-plugin-replies/ReplyBox.js @@ -11,7 +11,7 @@ const ReplyBox = (props) =>