Skip to content

Commit 5f0c1ff

Browse files
committed
Render Step.Loading while fetching sections
1 parent b506cc2 commit 5f0c1ff

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

client/sections-middleware.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import config from '@automattic/calypso-config';
22
import page from '@automattic/calypso-router';
3+
import { Step } from '@automattic/onboarding';
34
import * as LoadingError from 'calypso/layout/error';
5+
import { isInStepContainerV2FlowContext } from 'calypso/layout/utils';
46
import { performanceTrackerStart } from 'calypso/lib/performance-tracking';
57
import { bumpStat } from 'calypso/state/analytics/actions';
68
import { setSectionLoading } from 'calypso/state/ui/actions';
@@ -86,6 +88,17 @@ function loadSectionHandler( sectionDefinition ) {
8688
};
8789
}
8890

91+
function emptyPageLoading( context, next ) {
92+
if ( ! isInStepContainerV2FlowContext( context.pathname, context.querystring ) ) {
93+
return next();
94+
}
95+
96+
context.layout = <Step.Loading />;
97+
controller.render( context );
98+
99+
next();
100+
}
101+
89102
function createPageDefinition( path, sectionDefinition ) {
90103
// skip this section if it's not enabled in current environment
91104
const { envId } = sectionDefinition;
@@ -106,6 +119,10 @@ function createPageDefinition( path, sectionDefinition ) {
106119
handler = composeHandlers( controller.redirectLoggedOut, handler );
107120
}
108121

122+
if ( path === '/checkout' ) {
123+
handler = composeHandlers( emptyPageLoading, handler );
124+
}
125+
109126
page( pathRegex, handler );
110127
}
111128

0 commit comments

Comments
 (0)