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 duplicate API calls in error state handling #457

Merged
merged 1 commit into from
Feb 9, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from '@wordpress/element';
import { useEffect, useRef } from '@wordpress/element';
import { useLocation } from 'react-router-dom';
import { useSelect, useDispatch } from '@wordpress/data';

Expand Down Expand Up @@ -61,6 +61,8 @@
const { setCurrentOnboardingData, updateSiteGenErrorStatus } =
useDispatch( nfdOnboardingStore );

const prevSiteGenErrorStatus = useRef();

async function syncStoreToDB() {
if ( currentData ) {
//Set the Flow Data and sync store and DB
Expand All @@ -72,7 +74,6 @@
case SKIP_FLOW_ERROR_CODE_20:
break;
default:
currentData.sitegen.siteGenErrorStatus = true;
updateSiteGenErrorStatus( true );
break;
}
Expand Down Expand Up @@ -111,7 +112,6 @@
retryCount + 1
);
} else {
currentData.sitegen.siteGenErrorStatus = true;
updateSiteGenErrorStatus( true );
}
}
Expand Down Expand Up @@ -172,20 +172,21 @@
initializePlugins( pluginInstallHash );
setInterval( cronTrigger, 45000 );
}
}, [ initialize ] );

Check warning on line 175 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

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

useEffect( () => {
syncStoreToDB();
generateSiteGenData();
handlePreviousStepTracking();
}, [ location.pathname ] );

Check warning on line 181 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'generateSiteGenData', 'handlePreviousStepTracking', and 'syncStoreToDB'. Either include them or remove the dependency array

useEffect( () => {
if ( ! siteGenErrorStatus ) {
if ( prevSiteGenErrorStatus.current === true && siteGenErrorStatus === false ) {
generateSiteGenData();
syncStoreToDB();
}
prevSiteGenErrorStatus.current = siteGenErrorStatus;
}, [ siteGenErrorStatus ] );

Check warning on line 189 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'generateSiteGenData' and 'syncStoreToDB'. Either include them or remove the dependency array

useEffect( () => {
initializeThemes();
Expand Down
Loading