Skip to content

Commit

Permalink
Final improvements from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
paulopmt1 committed Jan 24, 2025
1 parent dc5b68f commit c3314f5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ const Launchpad: Step = ( { navigation, flow }: LaunchpadProps ) => {
}
}, [ verifiedParam, translate, dispatch ] );

// Avoid screen flickering when redirecting to other paths
if ( ! site?.options ) {
return null;
}

if ( launchpadScreenOption === 'skipped' ) {
window.location.assign( `/home/${ siteSlug }` );
return;
return null;
}

if ( shouldShowLaunchpadFirst( site?.options?.site_creation_flow ) ) {
if ( shouldShowLaunchpadFirst( site ) ) {
window.location.replace( `/home/${ siteSlug }` );
return;
}

// Avoid screen flickering when redirecting to other paths
if ( ! site?.options ) {
return;
return null;
}

return (
Expand Down
7 changes: 2 additions & 5 deletions client/my-sites/customer-home/controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ export default async function renderHome( context, next ) {
}

context.primary = (
<CustomerHome
key={ site.ID }
showLaunchpadFirst={ shouldShowLaunchpadFirst( site?.options?.site_creation_flow ) }
/>
<CustomerHome key={ site.ID } showLaunchpadFirst={ shouldShowLaunchpadFirst( site ) } />
);

next();
Expand Down Expand Up @@ -82,7 +79,7 @@ export async function maybeRedirect( context, next ) {

const site = getSelectedSite( state );

if ( shouldShowLaunchpadFirst( site?.options?.site_creation_flow ) ) {
if ( shouldShowLaunchpadFirst( site ) ) {
return next();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import config from '@automattic/calypso-config';
import { SiteDetails } from '@automattic/data-stores';

/**
* Determines if the launchpad should be shown first based on site createion flow
* @param {string|undefined} siteCreationFlow Site creation flow
* @param {SiteDetails|undefined} site Site object
* @returns {boolean} Whether launchpad should be shown first
*/
export const shouldShowLaunchpadFirst = ( siteCreationFlow ) => {
const wasSiteCreatedOnboardingFlow = siteCreationFlow === 'onboarding';
export const shouldShowLaunchpadFirst = ( site: SiteDetails ) => {
const wasSiteCreatedOnboardingFlow = site?.options?.site_creation_flow === 'onboarding';
const isLaunchpadFirstEnabled = config.isEnabled( 'home/launchpad-first' );

return wasSiteCreatedOnboardingFlow && isLaunchpadFirstEnabled;
Expand Down

0 comments on commit c3314f5

Please sign in to comment.