Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor homepage flicker #458

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@
currentData.sitegen.homepages.data = homepages;
currentData.sitegen.homepages.active = activeHomepage;
setCurrentOnboardingData( currentData );
return currentData;
}
await setFlow( currentData );
await completeFlow();
Expand All @@ -215,7 +214,7 @@

useEffect( () => {
handleCustomize();
}, [] );

Check warning on line 217 in src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'handleCustomize'. Either include it or remove the dependency array

useEffect( () => {
if ( currentData?.sitegen?.homepages?.active ) {
Expand Down
26 changes: 17 additions & 9 deletions src/OnboardingSPA/steps/SiteGen/Preview/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
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';
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();
Expand All @@ -23,6 +22,8 @@
const [ isPreviewLoading, setIsPreviewLoading ] = useState( false );
const [ globalStyles, setGlobalStyles ] = useState( false );

const prevSiteGenErrorStatus = useRef();

const {
setIsHeaderEnabled,
setSidebarActiveView,
Expand Down Expand Up @@ -53,11 +54,18 @@
setHeaderActiveView( HEADER_SITEGEN );
setDrawerActiveView( false );
updateInitialize( true );
if ( ! siteGenErrorStatus ) {
}, [ currentData ] );

Check warning on line 57 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'setDrawerActiveView', 'setHeaderActiveView', 'setHideFooterNav', 'setIsHeaderEnabled', 'setSidebarActiveView', and 'updateInitialize'. Either include them or remove the dependency array

useEffect( () => {
if (
prevSiteGenErrorStatus.current === true &&
siteGenErrorStatus === false
) {
loadHomepages();
loadGlobalStyles();
}
}, [ currentData ] );
prevSiteGenErrorStatus.current = siteGenErrorStatus;
}, [ siteGenErrorStatus ] );

Check warning on line 68 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'loadHomepages'. Either include it or remove the dependency array

const loadHomepages = async () => {
setIsPreviewLoading( true );
Expand Down Expand Up @@ -99,7 +107,7 @@
useEffect( () => {
loadHomepages();
loadGlobalStyles();
}, [] );

Check warning on line 110 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'loadHomepages'. Either include it or remove the dependency array

const handlePreview = ( slug ) => {
if ( ! ( slug in homepages ) ) {
Expand Down
Loading