Add resolution check to ensure setup-wizard redirection on homescreen is stable (https://github.com/woocommerce/woocommerce-admin/pull/8114)

* Add resolution check to ensure setup-wizard redirection is stable

* Add changelogs
This commit is contained in:
Chi-Hsuan Huang 2022-01-06 09:47:09 +08:00 committed by GitHub
parent 91fc05dcfe
commit 0c028b4a87
2 changed files with 21 additions and 7 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: Fix
Ensure setup-wizard redirection on homescreen is stable. #8114

View File

@ -18,13 +18,19 @@ import type { History } from 'history';
import Layout from './layout'; import Layout from './layout';
type HomescreenProps = ReturnType< typeof withSelectHandler > & { type HomescreenProps = ReturnType< typeof withSelectHandler > & {
hasFinishedResolution: boolean;
query: Record< string, string >; query: Record< string, string >;
}; };
const Homescreen = ( { profileItems, query }: HomescreenProps ) => { const Homescreen = ( {
const { completed: profilerCompleted, skipped: profilerSkipped } = profileItems: {
profileItems || {}; completed: profilerCompleted,
if ( ! profilerCompleted && ! profilerSkipped ) { skipped: profilerSkipped,
} = {},
hasFinishedResolution,
query,
}: HomescreenProps ) => {
if ( hasFinishedResolution && ! profilerCompleted && ! profilerSkipped ) {
( getHistory() as History ).push( ( getHistory() as History ).push(
getNewPath( {}, '/setup-wizard', {} ) getNewPath( {}, '/setup-wizard', {} )
); );
@ -36,10 +42,14 @@ const Homescreen = ( { profileItems, query }: HomescreenProps ) => {
const onboardingData = getSetting( 'onboarding', {} ); const onboardingData = getSetting( 'onboarding', {} );
const withSelectHandler = ( select: WCDataSelector ) => { const withSelectHandler = ( select: WCDataSelector ) => {
const { getProfileItems } = select( ONBOARDING_STORE_NAME ); const { getProfileItems, hasFinishedResolution } = select(
const profileItems = getProfileItems(); ONBOARDING_STORE_NAME
);
return { profileItems }; return {
profileItems: getProfileItems(),
hasFinishedResolution: hasFinishedResolution( 'getProfileItems', [] ),
};
}; };
export default compose( export default compose(