fix: cys intro screen parallelised network calls (#40827)
This commit is contained in:
parent
2c557f6d30
commit
a1505531bb
|
@ -18,15 +18,53 @@ export const fetchThemeCards = async () => {
|
|||
};
|
||||
|
||||
export const fetchIntroData = async () => {
|
||||
let currentThemeIsAiGenerated = false;
|
||||
const currentTemplate = await resolveSelect(
|
||||
coreStore
|
||||
const currentTemplatePromise =
|
||||
// @ts-expect-error No types for this exist yet.
|
||||
).__experimentalGetTemplateForLink( '/' );
|
||||
const maybePreviousTemplate = await resolveSelect(
|
||||
resolveSelect( coreStore ).__experimentalGetTemplateForLink( '/' );
|
||||
|
||||
const maybePreviousTemplatePromise = resolveSelect(
|
||||
OPTIONS_STORE_NAME
|
||||
).getOption( 'woocommerce_admin_customize_store_completed_theme_id' );
|
||||
|
||||
const styleRevsPromise =
|
||||
// @ts-expect-error No types for this exist yet.
|
||||
resolveSelect( coreStore ).getCurrentThemeGlobalStylesRevisions();
|
||||
|
||||
// @ts-expect-error No types for this exist yet.
|
||||
const hasModifiedPagesPromise = resolveSelect( coreStore ).getEntityRecords(
|
||||
'postType',
|
||||
'page',
|
||||
{
|
||||
per_page: 100,
|
||||
_fields: [ 'id', '_links.version-history' ],
|
||||
orderby: 'menu_order',
|
||||
order: 'asc',
|
||||
}
|
||||
);
|
||||
|
||||
const getTaskPromise = resolveSelect( ONBOARDING_STORE_NAME ).getTask(
|
||||
'customize-store'
|
||||
);
|
||||
|
||||
const themeDataPromise = fetchThemeCards();
|
||||
|
||||
const [
|
||||
currentTemplate,
|
||||
maybePreviousTemplate,
|
||||
styleRevs,
|
||||
rawPages,
|
||||
task,
|
||||
themeData,
|
||||
] = await Promise.all( [
|
||||
currentTemplatePromise,
|
||||
maybePreviousTemplatePromise,
|
||||
styleRevsPromise,
|
||||
hasModifiedPagesPromise,
|
||||
getTaskPromise,
|
||||
themeDataPromise,
|
||||
] );
|
||||
|
||||
let currentThemeIsAiGenerated = false;
|
||||
if (
|
||||
maybePreviousTemplate &&
|
||||
currentTemplate?.id === maybePreviousTemplate
|
||||
|
@ -34,33 +72,18 @@ export const fetchIntroData = async () => {
|
|||
currentThemeIsAiGenerated = true;
|
||||
}
|
||||
|
||||
const styleRevs = await resolveSelect(
|
||||
coreStore
|
||||
// @ts-expect-error No types for this exist yet.
|
||||
).getCurrentThemeGlobalStylesRevisions();
|
||||
|
||||
const hasModifiedPages = (
|
||||
await resolveSelect( coreStore )
|
||||
// @ts-expect-error No types for this exist yet.
|
||||
.getEntityRecords( 'postType', 'page', {
|
||||
per_page: 100,
|
||||
_fields: [ 'id', '_links.version-history' ],
|
||||
orderby: 'menu_order',
|
||||
order: 'asc',
|
||||
} )
|
||||
)?.some( ( page: { _links: { [ key: string ]: string[] } } ) => {
|
||||
const hasModifiedPages = rawPages?.some(
|
||||
( page: { _links: { [ key: string ]: string[] } } ) => {
|
||||
return page._links?.[ 'version-history' ]?.length > 1;
|
||||
} );
|
||||
|
||||
const { getTask } = resolveSelect( ONBOARDING_STORE_NAME );
|
||||
}
|
||||
);
|
||||
|
||||
const activeThemeHasMods =
|
||||
!! currentTemplate?.modified ||
|
||||
styleRevs?.length > 0 ||
|
||||
hasModifiedPages;
|
||||
const customizeStoreTaskCompleted = ( await getTask( 'customize-store' ) )
|
||||
?.isComplete;
|
||||
const themeData = await fetchThemeCards();
|
||||
|
||||
const customizeStoreTaskCompleted = task?.isComplete;
|
||||
|
||||
return {
|
||||
activeThemeHasMods,
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Parallelised the independent network calls on the intro screen so that they become much faster
|
Loading…
Reference in New Issue