devmadhuu commented on code in PR #10420:
URL: https://github.com/apache/ozone/pull/10420#discussion_r3362009823


##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/capacity/capacity.tsx:
##########
@@ -192,24 +184,22 @@ const Capacity: React.FC<object> = () => {
     }
   };
 
-  // Poll every 5s until status is FINISHED, then stop
+  // Poll DN pending deletion every 5s until status is FINISHED
   React.useEffect(() => {
-    if (dnPendingDeletes.data.status !== "FINISHED") {
-      if (!autoReload.isPolling) {
-        autoReload.startPolling(PENDING_POLL_INTERVAL);
-      }
+    if (dnPendingDeletes.data.status === "FINISHED") {
       return;
     }
 
-    if (autoReload.isPolling) {
-      autoReload.stopPolling();
-    }
-  }, [
-    dnPendingDeletes.data.status,
-    autoReload.isPolling,
-    autoReload.startPolling,
-    autoReload.stopPolling
-  ]);
+    dnPendingDeletes.refetch();
+
+    const intervalId = window.setInterval(() => {
+      dnPendingDeletes.refetch();
+    }, PENDING_POLL_INTERVAL);

Review Comment:
   Here, Replace the whole standalone setInterval effect with a tiny 
interval-selector 
   
   ```
   const autoReload = useAutoReload(loadData); // default 60s
   
   // One timer for everything: poll fast while a DN scan is running,
   // fall back to the normal interval once it finishes.
   React.useEffect(() => {
     if (!autoReload.isPolling) {
       return; // toggle is OFF — honor it for ALL refreshing
     }
     autoReload.startPolling(
       dnPendingDeletes.data.status === "FINISHED"
         ? AUTO_RELOAD_INTERVAL_DEFAULT
         : PENDING_POLL_INTERVAL
     );
   }, [dnPendingDeletes.data.status, autoReload.isPolling]); // 
eslint-disable-line react-hooks/exhaustive-deps
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to