From c588aed185810525493d19891806bf1805f4805c Mon Sep 17 00:00:00 2001 From: flaque Date: Sun, 8 Dec 2024 10:31:20 -0800 Subject: [PATCH] avoid hanging after adding a user --- src/lib/clusters/clusters.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/clusters/clusters.tsx b/src/lib/clusters/clusters.tsx index b31fa32..baeae2a 100644 --- a/src/lib/clusters/clusters.tsx +++ b/src/lib/clusters/clusters.tsx @@ -8,7 +8,7 @@ import { syncKubeconfig, } from "./kubeconfig.ts"; import yaml from "yaml"; -import { Box, render, Text } from "ink"; +import { Box, render, Text, useApp } from "ink"; import React from "react"; import { Row } from "../Row.tsx"; import { useCallback, useEffect, useRef, useState } from "react"; @@ -239,10 +239,16 @@ function UserAddedDisplay(props: { username: string; }) { const [isReady, setIsReady] = useState(false); + const { exit } = useApp(); useEffect(() => { const interval = setInterval(() => { - isCredentialReady(props.id).then(setIsReady); + isCredentialReady(props.id).then((ready) => { + setIsReady(ready); + setTimeout(() => { + exit(); + }, 0); + }); }, 200); return () => clearInterval(interval); }, [props.id]);