From e2b2e22edfc8453c4c9308952632095f2dac2131 Mon Sep 17 00:00:00 2001 From: "yongen.loong" Date: Fri, 15 Nov 2024 14:50:40 +0800 Subject: [PATCH] feat: timeout --- components/workspace/use-cli-commands.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/workspace/use-cli-commands.tsx b/components/workspace/use-cli-commands.tsx index e4d84f6..5e64971 100644 --- a/components/workspace/use-cli-commands.tsx +++ b/components/workspace/use-cli-commands.tsx @@ -365,6 +365,7 @@ function CheckProposalId({ id }: { id: string }) { function CheckProposalInfo({ id }: { id: string }) { const [releasedTxId, setReleasedTxId] = useState(); + const [timedOut, setTimedOut] = useState(false); const {data, loading} = useProposalsInfo( [id], @@ -376,6 +377,16 @@ function CheckProposalInfo({ id }: { id: string }) { setReleasedTxId(releasedTxId); }, [loading]); + useEffect(() => { + setTimedOut(false); + const timer = setTimeout(() => { + setTimedOut(true); + }, 120000); + return () => clearTimeout(timer); + }, [id]) + + if (timedOut) return

Timed out. Please check the status later.

; + return ( <>

Proposal status: {releasedTxId ? 'released' : 'pending'}