From 324e82c070aa41f34d7095c89bd27552ff615a29 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Wed, 3 May 2017 10:20:03 -0600 Subject: [PATCH] not pretty, but it works --- .../src/graphql/mutations/index.js | 30 +++++++++++++++++-- .../coral-admin/src/graphql/queries/index.js | 6 ---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/client/coral-admin/src/graphql/mutations/index.js b/client/coral-admin/src/graphql/mutations/index.js index 4d62201d1..684a60372 100644 --- a/client/coral-admin/src/graphql/mutations/index.js +++ b/client/coral-admin/src/graphql/mutations/index.js @@ -54,7 +54,20 @@ export const setCommentStatus = graphql(SET_COMMENT_STATUS, { }, updateQueries: { ModQueue: (oldData) => { - const comment = oldData.all.find(c => c.id === commentId); + 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 accepted; let acceptedCount = oldData.acceptedCount; @@ -97,7 +110,20 @@ export const setCommentStatus = graphql(SET_COMMENT_STATUS, { }, updateQueries: { ModQueue: (oldData) => { - const comment = oldData.all.find(c => c.id === commentId); + 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 rejected; let rejectedCount = oldData.rejectedCount; diff --git a/client/coral-admin/src/graphql/queries/index.js b/client/coral-admin/src/graphql/queries/index.js index 7b6985cba..c251e5759 100644 --- a/client/coral-admin/src/graphql/queries/index.js +++ b/client/coral-admin/src/graphql/queries/index.js @@ -71,12 +71,6 @@ export const loadMore = (fetchMore) => ({limit, cursor, sort, tab, asset_id}) => ] }; - // if we're not in the all tab, put the new comments in there anyway - // this way the acceptComment and rejectComment mutations don't break - if (tab !== 'all') { - updatedData.all = [...updatedData.all, ...comments]; - } - return updatedData; } });