From 12e29b947746a06a9bc4c753ede9d87bfd532792 Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Tue, 12 Feb 2019 16:58:01 +0000
Subject: [PATCH] GH-877: control when the polling is operational

---
 opentech/static_src/src/app/src/containers/NoteListing.js | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/opentech/static_src/src/app/src/containers/NoteListing.js b/opentech/static_src/src/app/src/containers/NoteListing.js
index eea06b58e..23eb7fc19 100644
--- a/opentech/static_src/src/app/src/containers/NoteListing.js
+++ b/opentech/static_src/src/app/src/containers/NoteListing.js
@@ -19,13 +19,17 @@ import {
 const NoteListing = ({loadNotes, submissionID, noteIDs, isErrored, errorMessage, isLoading }) => {
     const fetchNotes = () => loadNotes(submissionID)
 
+    const {start, stop } = useInterval(fetchNotes, 30000)
+
     useEffect( () => {
         if ( submissionID ) {
             fetchNotes()
+            start()
+        } else {
+            stop()
         }
     }, [submissionID])
 
-    useInterval(fetchNotes, 30000)
 
     const handleRetry = () => {
         if (!isLoading || isErrored) {
-- 
GitLab