diff --git a/client/coral-admin/src/reducers/comments.js b/client/coral-admin/src/reducers/comments.js index 2842e2289..01f536f71 100644 --- a/client/coral-admin/src/reducers/comments.js +++ b/client/coral-admin/src/reducers/comments.js @@ -39,7 +39,7 @@ const updateStatus = (state, action) => { // Flag a comment const flag = (state, action) => { const byId = state.get('byId'); - const data = byId.get(action.id).get('data').set('flagged', true); + const data = byId.get(action.id).set('flagged', true); const comment = byId.get(action.id).set('data', data); return state.set('byId', byId.set(action.id, comment)); }; diff --git a/client/coral-admin/src/services/talk-adapter.js b/client/coral-admin/src/services/talk-adapter.js index ce2e2692a..8122bc709 100644 --- a/client/coral-admin/src/services/talk-adapter.js +++ b/client/coral-admin/src/services/talk-adapter.js @@ -29,15 +29,20 @@ export default store => next => action => { // Get comments to fill each of the three lists on the mod queue const fetchModerationQueueComments = store => -fetch('/api/v1/queue') -.then(res => res.json()) + +Promise.all([fetch('/api/v1/comments/status/pending'), fetch('/api/v1/comments/status/rejected'), fetch('/api/v1/comments/action/flag')]) +.then(res => Promise.all(res.map(r => r.json()))) +.then(res => { + res[2] = res[2].map(comment => { comment.flagged = true; return comment; }); + return res.reduce((prev, curr) => prev.concat(curr), []); +}) .then(res => store.dispatch({type: 'COMMENTS_MODERATION_QUEUE_FETCH_SUCCESS', comments: res})) .catch(error => store.dispatch({type: 'COMMENTS_MODERATION_QUEUE_FETCH_FAILED', error})); // Update a comment. Now to update a comment we need to send back the whole object const updateComment = (store, comment) => -fetch(`/api/v1/comments/${comment._id}/status`, { +fetch('/api/v1/comments/${comment._id}/status', { method: 'POST', body: JSON.stringify({status: comment.status}) }) diff --git a/package.json b/package.json index a3656ddba..694922148 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,10 @@ "babel-core": "^6.18.2", "babel-loader": "^6.2.7", "babel-plugin-transform-async-to-generator": "^6.16.0", + "babel-plugin-transform-class-properties": "^6.18.0", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-object-assign": "^6.8.0", + "babel-plugin-transform-object-rest-spread": "^6.16.0", "babel-plugin-transform-react-jsx": "^6.8.0", "babel-polyfill": "^6.16.0", "babel-preset-es2015": "^6.18.0",