From 8c215e08612dbe6ce870434620ff1c5fb14f312c Mon Sep 17 00:00:00 2001 From: Dan Zajdband Date: Tue, 8 Nov 2016 17:15:57 -0500 Subject: [PATCH 1/2] api-adapt(coral-admin): Get flagging mod queue working with the backend --- client/coral-admin/src/reducers/comments.js | 2 +- client/coral-admin/src/services/talk-adapter.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/coral-admin/src/reducers/comments.js b/client/coral-admin/src/reducers/comments.js index 4fd14673a..e75079ce4 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 2336e0cfd..0772bb24a 100644 --- a/client/coral-admin/src/services/talk-adapter.js +++ b/client/coral-admin/src/services/talk-adapter.js @@ -29,8 +29,12 @@ 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 })) From f708271d0003dd9de5df2295f70adbd3e3a42a03 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 9 Nov 2016 09:03:25 -0700 Subject: [PATCH 2/2] Added missing babel plugin --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 979475b5b..5be396a32 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,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",