From c78e00711a61f3e9e2426328d5e63d688105b7ee Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Wed, 3 May 2017 10:54:52 -0600 Subject: [PATCH] remove if statements --- .../src/graphql/mutations/index.js | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/client/coral-admin/src/graphql/mutations/index.js b/client/coral-admin/src/graphql/mutations/index.js index 684a60372..9c72d184a 100644 --- a/client/coral-admin/src/graphql/mutations/index.js +++ b/client/coral-admin/src/graphql/mutations/index.js @@ -54,20 +54,12 @@ export const setCommentStatus = graphql(SET_COMMENT_STATUS, { }, updateQueries: { ModQueue: (oldData) => { - let comment = oldData.all.find(c => c.id === commentId); - - if (!comment) { - comment = oldData.premod.find(c => c.id === commentId); - } - - if (!comment) { - comment = oldData.flagged.find(c => c.id === commentId); - } - - if (!comment) { - comment = oldData.rejected.find(c => c.id === commentId); - } - + let comment = [ + ...oldData.all, + ...oldData.premod, + ...oldData.flagged, + ...oldData.rejected + ].find(c => c.id === commentId); let accepted; let acceptedCount = oldData.acceptedCount; @@ -110,19 +102,12 @@ export const setCommentStatus = graphql(SET_COMMENT_STATUS, { }, updateQueries: { ModQueue: (oldData) => { - let comment = oldData.all.find(c => c.id === commentId); - - if (!comment) { - comment = oldData.premod.find(c => c.id === commentId); - } - - if (!comment) { - comment = oldData.flagged.find(c => c.id === commentId); - } - - if (!comment) { - comment = oldData.accepted.find(c => c.id === commentId); - } + let comment = [ + ...oldData.all, + ...oldData.premod, + ...oldData.flagged, + ...oldData.accepted + ].find(c => c.id === commentId); let rejected; let rejectedCount = oldData.rejectedCount;