api-adapt(coral-admin): Get flagging mod queue working with the backend

This commit is contained in:
Dan Zajdband
2016-11-08 17:15:57 -05:00
parent 5270aefe6a
commit 8c215e0861
2 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -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))
}
@@ -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 }))