From 3c8c8aec75f75fdf10906be600ed3170554fea39 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Fri, 9 Feb 2024 23:58:30 +0530 Subject: [PATCH 1/2] Fix minor homepage flicker --- .../steps/SiteGen/Preview/index.js | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/OnboardingSPA/steps/SiteGen/Preview/index.js b/src/OnboardingSPA/steps/SiteGen/Preview/index.js index 3be4bf33a..030a782ec 100644 --- a/src/OnboardingSPA/steps/SiteGen/Preview/index.js +++ b/src/OnboardingSPA/steps/SiteGen/Preview/index.js @@ -1,11 +1,12 @@ -import CommonLayout from '../../../components/Layouts/Common'; - -import { useEffect, useState } from '@wordpress/element'; +import { useEffect, useState, useRef } from '@wordpress/element'; import { useSelect, useDispatch } from '@wordpress/data'; -import { store as nfdOnboardingStore } from '../../../store'; -import { HEADER_SITEGEN } from '../../../../constants'; import { useNavigate } from 'react-router-dom'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { cloneDeep, isEmpty } from 'lodash'; +import CommonLayout from '../../../components/Layouts/Common'; +import { store as nfdOnboardingStore } from '../../../store'; +import { HEADER_SITEGEN } from '../../../../constants'; import { SiteGenPreviewSelectableCard } from '../../../components/LivePreview'; import getContents from './contents'; import HeartAnimation from './heartAnimation'; @@ -13,8 +14,6 @@ import RegeneratingSiteCard from './regeneratingCard'; import { getHomepages, regenerateHomepage } from '../../../utils/api/siteGen'; import { getGlobalStyles } from '../../../utils/api/themes'; import SitegenAiStateHandler from '../../../components/StateHandlers/SitegenAi'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { cloneDeep, isEmpty } from 'lodash'; const SiteGenPreview = () => { const navigate = useNavigate(); @@ -23,6 +22,8 @@ const SiteGenPreview = () => { const [ isPreviewLoading, setIsPreviewLoading ] = useState( false ); const [ globalStyles, setGlobalStyles ] = useState( false ); + const prevSiteGenErrorStatus = useRef(); + const { setIsHeaderEnabled, setSidebarActiveView, @@ -53,11 +54,18 @@ const SiteGenPreview = () => { setHeaderActiveView( HEADER_SITEGEN ); setDrawerActiveView( false ); updateInitialize( true ); - if ( ! siteGenErrorStatus ) { + }, [ currentData ] ); + + useEffect( () => { + if ( + prevSiteGenErrorStatus.current === true && + siteGenErrorStatus === false + ) { loadHomepages(); loadGlobalStyles(); } - }, [ currentData ] ); + prevSiteGenErrorStatus.current = siteGenErrorStatus; + }, [ siteGenErrorStatus ] ); const loadHomepages = async () => { setIsPreviewLoading( true ); From d24d826c3d818b502ef63403443cb99c02b24e12 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Sat, 10 Feb 2024 00:08:19 +0530 Subject: [PATCH 2/2] Remove return --- src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js b/src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js index 9fc345c64..39e164a38 100644 --- a/src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js +++ b/src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js @@ -206,7 +206,6 @@ const StepSiteGenEditorHeader = () => { currentData.sitegen.homepages.data = homepages; currentData.sitegen.homepages.active = activeHomepage; setCurrentOnboardingData( currentData ); - return currentData; } await setFlow( currentData ); await completeFlow();