From 47bcd163b18f9c9aa9336f5d06f0b5342dfef6f7 Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 17:56:44 -0500 Subject: [PATCH 1/2] Showing comments in chronological order. --- client/coral-framework/store/actions/items.js | 7 ++++--- client/coral-framework/store/reducers/items.js | 7 ++++++- client/coral-plugin-commentbox/CommentBox.js | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index 351986ce2..0b23098bb 100644 --- a/client/coral-framework/store/actions/items.js +++ b/client/coral-framework/store/actions/items.js @@ -56,12 +56,13 @@ export const updateItem = (id, property, value) => { } } -export const appendItemArray = (id, property, value) => { +export const appendItemArray = (id, property, value, addToFront) => { return { type: APPEND_ITEM_ARRAY, id, property, - value + value, + addToFront } } @@ -115,7 +116,7 @@ export function getStream (assetId) { const keys = Object.keys(childComments) for (var i=0; i < keys.length; i++ ) { - dispatch(updateItem(keys[i], 'children', childComments[keys[i]])) + dispatch(updateItem(keys[i], 'children', childComments[keys[i]].reverse())) } return (json) diff --git a/client/coral-framework/store/reducers/items.js b/client/coral-framework/store/reducers/items.js index 8242ddcb3..d3eb4d3af 100644 --- a/client/coral-framework/store/reducers/items.js +++ b/client/coral-framework/store/reducers/items.js @@ -15,7 +15,12 @@ export default (state = initialState, action) => { ) case actions.APPEND_ITEM_ARRAY: return state.updateIn([action.id, action.property], (prop) => { - return prop ? prop.unshift(action.value) : fromJS([action.value]) + if (action.addToFront) { + return prop ? prop.unshift(action.value) : fromJS([action.value]) + } else { + return prop ? prop.push(action.value) : fromJS([action.value]) + } + } ) default: diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index b7d282f10..c763cb82a 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) + appendItemArray(parent_id || id, related, comment_id, parent_id ? true : false) addNotification('success', 'Your comment has been posted.') }).catch((err) => console.error(err)) this.setState({body: ''}) From 456524e4ee022f877e56fbd6ad1be74c8c6c0bdb Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 18:09:26 -0500 Subject: [PATCH 2/2] Adding multiline comments. --- client/coral-embed-stream/src/CommentStream.js | 4 ++-- client/coral-embed-stream/style/default.css | 1 + .../CommentContent.js | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 47a57200e..29b9e8361 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -121,7 +121,7 @@ class CommentStream extends Component {
- +
{ // - +
{ //
- {props.content} -
+const Content = ({body, styles}) => { + const textbreaks = body.split('\n') + return
+ { + textbreaks.map((line, i) => + {line}
+
) + } +
+} export default Content