From f73f8d916e1ee1a5d77d042690114462fdb11b97 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 16 Jun 2017 00:50:44 +0700 Subject: [PATCH] Only show notification once --- client/coral-admin/src/graphql/utils.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/coral-admin/src/graphql/utils.js b/client/coral-admin/src/graphql/utils.js index 9d85c6bb1..1a3262529 100644 --- a/client/coral-admin/src/graphql/utils.js +++ b/client/coral-admin/src/graphql/utils.js @@ -97,18 +97,27 @@ export function handleCommentStatusChange(root, comment, {sort, notify, user, ac let next = root; const nextQueues = getCommentQueues(comment); + let notificationShown = false; + const showNotificationOnce = (...args) => { + if (notificationShown) { + return; + } + showNotification(...args); + notificationShown = true; + }; + queues.forEach((queue) => { if (nextQueues.indexOf(queue) >= 0) { if (!queueHasComment(next, queue, comment.id)) { next = addCommentToQueue(next, queue, comment, sort); if (notify && activeQueue === queue && shouldCommentBeAdded(next, queue, comment, sort)) { - showNotification(queue, comment, user); + showNotificationOnce(queue, comment, user); } } } else if(queueHasComment(next, queue, comment.id)){ next = removeCommentFromQueue(next, queue, comment.id); if (notify && activeQueue === queue) { - showNotification(queue, comment, user); + showNotificationOnce(queue, comment, user); } } @@ -118,7 +127,7 @@ export function handleCommentStatusChange(root, comment, {sort, notify, user, ac && notify && activeQueue === queue ) { - showNotification(queue, comment, user); + showNotificationOnce(queue, comment, user); } // TODO: Flagged notification