From a3ec23c27349cfab390fc3fe16c5d22f3be2de16 Mon Sep 17 00:00:00 2001 From: riley Date: Thu, 27 Apr 2017 13:09:00 -0600 Subject: [PATCH] mange counts and such for all queue --- client/coral-admin/src/graphql/mutations/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/graphql/mutations/index.js b/client/coral-admin/src/graphql/mutations/index.js index 7ca1b078f..364243cb1 100644 --- a/client/coral-admin/src/graphql/mutations/index.js +++ b/client/coral-admin/src/graphql/mutations/index.js @@ -54,20 +54,26 @@ export const setCommentStatus = graphql(SET_COMMENT_STATUS, { }, updateQueries: { ModQueue: (oldData) => { + const comment = oldData.all.find(c => c.id === commentId); + comment.status = 'ACCEPTED'; const premod = oldData.premod.filter(c => c.id !== commentId); const flagged = oldData.flagged.filter(c => c.id !== commentId); + const accepted = [comment].concat(oldData.accepted); const rejected = oldData.rejected.filter(c => c.id !== commentId); const premodCount = premod.length < oldData.premod.length ? oldData.premodCount - 1 : oldData.premodCount; const flaggedCount = flagged.length < oldData.flagged.length ? oldData.flaggedCount - 1 : oldData.flaggedCount; const rejectedCount = rejected.length < oldData.rejected.length ? oldData.rejectedCount - 1 : oldData.rejectedCount; + const acceptedCount = oldData.acceptedCount + 1; return { ...oldData, premodCount, flaggedCount, + acceptedCount, rejectedCount, premod, flagged, + accepted, rejected, }; } @@ -82,21 +88,26 @@ export const setCommentStatus = graphql(SET_COMMENT_STATUS, { }, updateQueries: { ModQueue: (oldData) => { - const comment = oldData.premod.concat(oldData.flagged).filter(c => c.id === commentId)[0]; + const comment = oldData.all.find(c => c.id === commentId); + comment.status = 'REJECTED'; const rejected = [comment].concat(oldData.rejected); const premod = oldData.premod.filter(c => c.id !== commentId); const flagged = oldData.flagged.filter(c => c.id !== commentId); + const accepted = oldData.accepted.filter(c => c.id !== commentId); const premodCount = premod.length < oldData.premod.length ? oldData.premodCount - 1 : oldData.premodCount; const flaggedCount = flagged.length < oldData.flagged.length ? oldData.flaggedCount - 1 : oldData.flaggedCount; const rejectedCount = oldData.rejectedCount + 1; + const acceptedCount = accepted.length < oldData.accepted.length ? oldData.acceptedCount - 1 : oldData.acceptedCount; return { ...oldData, premodCount, flaggedCount, + acceptedCount, rejectedCount, premod, flagged, + accepted, rejected }; }