diff --git a/src/components/pages/admin/services/service/(partials)/cluster-server-views.tsx b/src/components/pages/admin/services/service/(partials)/cluster-server-views.tsx index 142c05b..f690e94 100644 --- a/src/components/pages/admin/services/service/(partials)/cluster-server-views.tsx +++ b/src/components/pages/admin/services/service/(partials)/cluster-server-views.tsx @@ -36,7 +36,10 @@ export default function ServiceClusterServerViews({ const viewRef = useRef(undefined); const { data } = useWebSocketEventHandler(); - const { isIntersecting } = useIntersectionObserver({ elementRef: viewRef }); + const { isIntersecting } = useIntersectionObserver({ + elementRef: viewRef, + options: { rootMargin: "-200px", threshold: 0 }, + }); const [ttyd, setTtyd] = useState(); @@ -56,7 +59,7 @@ export default function ServiceClusterServerViews({ } useEffect(() => { - if (!ws?.socket || WsReqSentRef.current) { + if (!ws?.socket || WsReqSentRef.current || !isIntersecting) { return; } @@ -80,11 +83,9 @@ export default function ServiceClusterServerViews({ return function () { sendKillPort(); }; - }, [ws, refresh]); + }, [ws, refresh, isIntersecting]); useEffect(() => { - console.log("log_cmd", log_cmd); - if (WsReqSentRef.current) { sendKillPort(); @@ -125,7 +126,10 @@ export default function ServiceClusterServerViews({ useEffect(() => { if (!ttyd?.port) return; - if (!isIntersecting) { + if (isIntersecting) { + WsReqSentRef.current = false; + setTtyd(undefined); + } else { sendKillPort(); } }, [isIntersecting]); diff --git a/src/websocket/events/client-service-server-logs.ts b/src/websocket/events/client-service-server-logs.ts index 38ea4ff..971688b 100644 --- a/src/websocket/events/client-service-server-logs.ts +++ b/src/websocket/events/client-service-server-logs.ts @@ -13,8 +13,6 @@ export default async function socketClientServiceServerLogs({ const server = data?.server; const cmd = data?.cmd; - console.log("cmd", cmd); - const ttyd = await grabTtydServerInfo({ server, service,