From e7f4f82f66c5b1d16f41bc18fed64007c0924729 Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 18:41:07 -0500 Subject: [PATCH 1/2] Fixing comment post order bug. --- client/coral-embed-stream/src/CommentStream.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 29b9e8361..cda7ffd57 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -54,8 +54,8 @@ const {setLoggedInUser} = authActions postAction: (item, action, user) => { return dispatch(postAction(item, action, user)) }, - appendItemArray: (item, property, value) => { - return dispatch(appendItemArray(item, property, value)) + appendItemArray: (item, property, value, addToFront) => { + return dispatch(appendItemArray(item, property, value, addToFront)) } } } From 33c77178a90bf276c50acddbe040b39ae8d8072a Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 18:41:23 -0500 Subject: [PATCH 2/2] Fixing id bug in redux store. --- client/coral-framework/store/actions/items.js | 8 ++++---- client/coral-plugin-commentbox/CommentBox.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index 0b23098bb..8b30e2548 100644 --- a/client/coral-framework/store/actions/items.js +++ b/client/coral-framework/store/actions/items.js @@ -186,13 +186,13 @@ export function postItem (item, type, id) { return fetch('/api/v1/' + type, options) .then( response => { - return response.ok ? response.text() + return response.ok ? response.json() : Promise.reject(response.status + ' ' + response.statusText) } ) - .then((id) => { - dispatch(addItem({...item, id})) - return id + .then((json) => { + dispatch(addItem({...item, id:json.id})) + return json.id }) } } diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index c763cb82a..0f1578859 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -35,7 +35,7 @@ class CommentBox extends Component { updateItem(parent_id, 'showReply', false) postItem(comment, 'comments') .then((comment_id) => { - appendItemArray(parent_id || id, related, comment_id, parent_id ? true : false) + appendItemArray(parent_id || id, related, comment_id, parent_id ? false : true) addNotification('success', 'Your comment has been posted.') }).catch((err) => console.error(err)) this.setState({body: ''})