From 4f3381815365afecc43efd7cf850bce82b69988f Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 17:12:20 -0500 Subject: [PATCH] Posting items in reverse chronological order. --- client/coral-framework/store/actions/items.js | 4 ++-- client/coral-framework/store/reducers/items.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index 443a41e94..351986ce2 100644 --- a/client/coral-framework/store/actions/items.js +++ b/client/coral-framework/store/actions/items.js @@ -91,8 +91,8 @@ export function getStream (assetId) { /* Sort comments by date*/ let rootComments = [] let childComments = {} - const sorted = json.sort((a,b) => b.created_at - a.created_at) - sorted.reduce((prev, item) => { + json.sort((a,b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()) + json.reduce((prev, item) => { dispatch(addItem(item)) /* Check for root and child comments. */ diff --git a/client/coral-framework/store/reducers/items.js b/client/coral-framework/store/reducers/items.js index 2bba3bf1b..8242ddcb3 100644 --- a/client/coral-framework/store/reducers/items.js +++ b/client/coral-framework/store/reducers/items.js @@ -15,7 +15,7 @@ export default (state = initialState, action) => { ) case actions.APPEND_ITEM_ARRAY: return state.updateIn([action.id, action.property], (prop) => { - return prop ? prop.push(action.value) : fromJS([action.value]) + return prop ? prop.unshift(action.value) : fromJS([action.value]) } ) default: