Просмотр исходного кода

Merge branch 'master' of github.com:porter-dev/porter into nico/expanded-chart-overhaul

jnfrati 4 лет назад
Родитель
Сommit
8b84bb0bd0
1 измененных файлов с 15 добавлено и 10 удалено
  1. 15 10
      dashboard/src/main/home/cluster-dashboard/expanded-chart/status/Logs.tsx

+ 15 - 10
dashboard/src/main/home/cluster-dashboard/expanded-chart/status/Logs.tsx

@@ -402,9 +402,7 @@ const useLogs = (
   useEffect(() => {
   useEffect(() => {
     console.log("Selected pod updated");
     console.log("Selected pod updated");
     if (currentPod?.metadata?.name === currentPodName.current) {
     if (currentPod?.metadata?.name === currentPodName.current) {
-      return () => {
-        closeAllWebsockets();
-      };
+      return () => {};
     }
     }
     currentPodName.current = currentPod?.metadata?.name;
     currentPodName.current = currentPod?.metadata?.name;
     const currentContainers =
     const currentContainers =
@@ -412,22 +410,19 @@ const useLogs = (
 
 
     setContainers(currentContainers);
     setContainers(currentContainers);
     setCurrentContainer(currentContainers[0]);
     setCurrentContainer(currentContainers[0]);
-    return () => {
-      closeAllWebsockets();
-    };
   }, [currentPod]);
   }, [currentPod]);
 
 
   // Retrieve all previous logs for containers
   // Retrieve all previous logs for containers
   useEffect(() => {
   useEffect(() => {
+    if (!Array.isArray(containers)) {
+      return;
+    }
+
     closeAllWebsockets();
     closeAllWebsockets();
 
 
     setPrevLogs({});
     setPrevLogs({});
     setLogs({});
     setLogs({});
 
 
-    if (!Array.isArray(containers)) {
-      return;
-    }
-
     getSystemLogs();
     getSystemLogs();
     containers.forEach((containerName) => {
     containers.forEach((containerName) => {
       const websocketKey = `${currentPodName.current}-${containerName}-websocket`;
       const websocketKey = `${currentPodName.current}-${containerName}-websocket`;
@@ -438,8 +433,18 @@ const useLogs = (
         setupWebsocket(containerName, websocketKey);
         setupWebsocket(containerName, websocketKey);
       }
       }
     });
     });
+
+    return () => {
+      closeAllWebsockets();
+    };
   }, [containers]);
   }, [containers]);
 
 
+  useEffect(() => {
+    return () => {
+      closeAllWebsockets();
+    };
+  }, []);
+
   const currentLogs = useMemo(() => {
   const currentLogs = useMemo(() => {
     return logs[currentContainer] || [];
     return logs[currentContainer] || [];
   }, [currentContainer, logs]);
   }, [currentContainer, logs]);