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

Merge branch 'meehawk/logs-improvement' of github.com-meehawk:porter-dev/porter into dev

Soham Parekh 3 лет назад
Родитель
Сommit
507151983e

+ 3 - 3
dashboard/src/main/home/cluster-dashboard/expanded-chart/logs-section/LogsSection.tsx

@@ -124,13 +124,13 @@ const LogsSection: React.FC<Props> = ({
   }, []);
 
   useEffect(() => {
-    if (scrollToBottomRef.current && scrollToBottomEnabled) {
+    if (!loading && scrollToBottomRef.current && scrollToBottomEnabled) {
       scrollToBottomRef.current.scrollIntoView({
         behavior: "smooth",
         block: "end",
       });
     }
-  }, [logs, scrollToBottomRef, scrollToBottomEnabled]);
+  }, [loading, logs, scrollToBottomRef, scrollToBottomEnabled]);
 
   const renderLogs = () => {
     return logs?.map((log, i) => {
@@ -257,9 +257,9 @@ const LogsSection: React.FC<Props> = ({
               >
                 Load more
               </LoadMoreButton>
-              <div ref={scrollToBottomRef} />
             </>
           )}
+          <div ref={scrollToBottomRef} />
         </StyledLogsSection>
       </>
     );

+ 3 - 3
dashboard/src/main/home/cluster-dashboard/expanded-chart/logs-section/useAgentLogs.ts

@@ -172,10 +172,10 @@ export const useLogs = (
       },
       onmessage: (evt: MessageEvent) => {
         // Nothing to do here
-        if (!evt.data || typeof evt.data !== "string") {
-          return;
+        if (!evt?.data || typeof evt.data !== "string") {
+          return
         }
-
+        
         const newLogs = parseLogs(
           evt?.data?.split("}\n").map((line: string) => line + "}")
         );