From 0066d442c9915a2d9d8286aa47e6c961ce354e07 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Fri, 5 Apr 2024 17:41:38 +0530 Subject: [PATCH] Add a site meta generation state --- .../NewfoldInterfaceSkeleton/SiteGen/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js index bbdeaac5f..ac19b48b9 100644 --- a/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js +++ b/src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js @@ -55,6 +55,7 @@ const ThemedNewfoldInterfaceSkeleton = themeToggleHOC( const SiteGen = () => { const [ failedSiteMetaAPIs, setFailedSiteMetaAPIs ] = useState( [] ); + const [ isGeneratingSiteMeta, setIsGeneratingSiteMeta ] = useState( false ); const { currentData, @@ -191,6 +192,7 @@ const SiteGen = () => { if ( siteGenErrorStatus === false ) { updateSiteGenErrorStatus( true ); + setIsGeneratingSiteMeta( false ); } if ( window.nfdOnboarding.siteGenTimerInterval ) { @@ -208,7 +210,7 @@ const SiteGen = () => { } ); } - // A Identifier request was sucessfuly made with valid response + // A Identifier request was successfully made with valid response currentData.sitegen.siteGenMetaStatus.currentStatus += 1; if ( @@ -217,7 +219,8 @@ const SiteGen = () => { ) { // Once all requests are completed use cache to get data currentData.sitegen.skipCache = false; - + // Increase count after site meta calls to ensure systematic call of homepages + currentData.sitegen.siteGenMetaStatus.totalCount += 1; // Get the homepages and set that in flow const response = await getHomepages( currentData.sitegen.siteDetails.prompt @@ -225,6 +228,8 @@ const SiteGen = () => { if ( response.body ) { currentData.sitegen.homepages.data = response.body; + currentData.sitegen.siteGenMetaStatus.currentStatus += 1; + setIsGeneratingSiteMeta( false ); } } // Sync the current request changed to State @@ -235,6 +240,7 @@ const SiteGen = () => { // Start the API Requests when the loader is shown. if ( true === siteGenErrorStatus || + true === isGeneratingSiteMeta || ( ! location.pathname.includes( 'site-logo' ) && ! location.pathname.includes( 'experience' ) ) ) { @@ -249,6 +255,8 @@ const SiteGen = () => { return; } + setIsGeneratingSiteMeta( true ); + if ( ! window.nfdOnboarding?.siteGenTimerInterval ) { window.nfdOnboarding.siteGenTime = 0; window.nfdOnboarding.siteGenTimerInterval = setInterval( () => {