Skip to content

Commit

Permalink
My Home doesn't navigate to launchpad if that's where it came from
Browse files Browse the repository at this point in the history
A mitigation for the issue in #98122
  • Loading branch information
p-jackson committed Jan 9, 2025
1 parent 4a1680e commit 4a11655
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ const Launchpad: Step = ( { navigation, flow }: LaunchpadProps ) => {

function redirectToSiteHome( siteSlug: string | null, flow: string | null ) {
recordTracksEvent( 'calypso_launchpad_redirect_to_home', { flow: flow } );
window.location.replace( `/home/${ siteSlug }` );
// Query param is a guard to prevent infinite loops (#98122)
window.location.replace( `/home/${ siteSlug }?from=full-launchpad` );
}

useEffect( () => {
Expand Down
18 changes: 12 additions & 6 deletions client/my-sites/customer-home/controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fetchLaunchpad } from '@automattic/data-stores';
import { areLaunchpadTasksCompleted } from 'calypso/landing/stepper/declarative-flow/internals/steps-repository/launchpad/task-helper';
import { isRemovedFlow } from 'calypso/landing/stepper/utils/flow-redirect-handler';
import { getQueryArgs } from 'calypso/lib/query-args';
import { bumpStat } from 'calypso/state/analytics/actions';
import { fetchModuleList } from 'calypso/state/jetpack/modules/actions';
import { fetchSitePlugins } from 'calypso/state/plugins/installed/actions';
import { getPluginOnSite } from 'calypso/state/plugins/installed/selectors';
Expand Down Expand Up @@ -40,7 +41,7 @@ export async function maybeRedirect( context, next ) {
return;
}

const { verified, courseSlug } = getQueryArgs() || {};
const { verified, courseSlug, from } = getQueryArgs() || {};

// The courseSlug is to display pages with onboarding videos for learning,
// so we should not redirect the page to launchpad.
Expand Down Expand Up @@ -75,11 +76,16 @@ export async function maybeRedirect( context, next ) {
launchpadScreenOption === 'full' &&
! areLaunchpadTasksCompleted( launchpadChecklist, isSiteLaunched )
) {
// The new stepper launchpad onboarding flow isn't registered within the "page"
// client-side router, so page.redirect won't work. We need to use the
// traditional window.location Web API.
redirectToLaunchpad( slug, siteIntentOption, verified );
return;
if ( from === 'full-launchpad' ) {
// A guard to prevent infinite loops (#98122)
context.store.dispatch( bumpStat( 'calypso_customer_home_launchpad_infinite_loop_guard' ) );
} else {
// The new stepper launchpad onboarding flow isn't registered within the "page"
// client-side router, so page.redirect won't work. We need to use the
// traditional window.location Web API.
redirectToLaunchpad( slug, siteIntentOption, verified );
return;
}
}
} catch ( error ) {}

Expand Down

0 comments on commit 4a11655

Please sign in to comment.