From 9405e6a96aeee588e3a3791dd42919c9529c2b60 Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Fri, 31 May 2024 15:28:42 +0200 Subject: [PATCH] Fix pending state --- src/pages/dashboard.tsx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index f304e64e5..9367a7924 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -117,6 +117,9 @@ export const Dashboard: React.FC = () => { } ); + const isPendingDao = + pendingDao || (isGasless && !(census3Token?.status.synced ?? false)); + const isLoading = liveDaoLoading || pendingDaoLoading || followedDaosLoading; const removePendingDaoMutation = useRemovePendingDaoMutation(() => { @@ -155,22 +158,29 @@ export const Dashboard: React.FC = () => { *************************************************/ useEffect(() => { // poll for the newly created DAO while waiting to be indexed - if (pendingDao && isSuccess && !liveDao) { + if (isPendingDao && isSuccess && !liveDao) { setPollInterval(1000); } - }, [isSuccess, liveDao, pendingDao]); + }, [isSuccess, liveDao, isPendingDao]); useEffect(() => { if ( - pendingDao && + isPendingDao && liveDao && - daoCreationState === DaoCreationState.ASSEMBLING_DAO + daoCreationState === DaoCreationState.ASSEMBLING_DAO && + (!isGasless || census3Token?.status.synced === true) ) { setPollInterval(0); setDaoCreationState(DaoCreationState.DAO_READY); setTimeout(() => setDaoCreationState(DaoCreationState.OPEN_DAO), 2000); } - }, [liveDao, daoCreationState, pendingDao]); + }, [ + liveDao, + daoCreationState, + isPendingDao, + isGasless, + census3Token?.status.synced, + ]); useEffect(() => { if ( @@ -260,7 +270,7 @@ export const Dashboard: React.FC = () => { return ; } - if (pendingDao) { + if (isPendingDao) { const buttonLabel = { [DaoCreationState.ASSEMBLING_DAO]: t('dashboard.emptyState.buildingDAO'), [DaoCreationState.DAO_READY]: t('dashboard.emptyState.daoReady'),