From 99290465366e35e59b76d26d34fea7b29b4f866a Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 1 Aug 2017 18:06:06 +0700 Subject: [PATCH] Fix reported queue take 2 --- client/coral-admin/src/graphql/utils.js | 34 ++++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/client/coral-admin/src/graphql/utils.js b/client/coral-admin/src/graphql/utils.js index 94161af00..f729cc0ea 100644 --- a/client/coral-admin/src/graphql/utils.js +++ b/client/coral-admin/src/graphql/utils.js @@ -64,29 +64,33 @@ function addCommentToQueue(root, queue, comment, sort) { return update(root, changes); } +/** + * getCommentQueues determines in which queues a comment should be placed. + */ function getCommentQueues(comment) { const queues = ['all']; + const isFlagged = comment.actions && comment.actions.some((a) => a.__typename === 'FlagAction'); - if (comment.status === 'ACCEPTED') { + switch(comment.status) { + case 'ACCEPTED': queues.push('approved'); - } - else if (comment.status === 'REJECTED') { + break; + case 'REJECTED': queues.push('rejected'); - } - else if (comment.status === 'PREMOD') { + break; + case 'PREMOD': queues.push('premod'); queues.push('new'); - } - else if (comment.status === 'NONE') { + if (isFlagged) { + queues.push('reported'); + } + break; + case 'NONE': queues.push('new'); - } - - // Additionally populate the `flagged` queue. - if ( - ['NONE', 'PREMOD'].indexOf(comment.status) >= 0 - && comment.actions && comment.actions.some((a) => a.__typename === 'FlagAction') - ) { - queues.push('flagged'); + if (isFlagged) { + queues.push('reported'); + } + break; } return queues;