mirror of
https://github.com/wassname/talk.git
synced 2026-08-14 12:50:17 +08:00
api-adapt(coral-admin): Get flagging mod queue working with the backend
This commit is contained in:
@@ -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 }))
|
||||
|
||||
Reference in New Issue
Block a user