Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader Onboarding: Do not render if user registered before Oct 1 2024 #95624

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions client/reader/following/main.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import config from '@automattic/calypso-config';
import clsx from 'clsx';
import { translate } from 'i18n-calypso';
import { useState } from 'react';
import AsyncLoad from 'calypso/components/async-load';
import BloganuaryHeader from 'calypso/components/bloganuary-header';
import NavigationHeader from 'calypso/components/navigation-header';
Expand All @@ -13,7 +13,8 @@ import FollowingIntro from './intro';
import './style.scss';

function FollowingStream( { ...props } ) {
/* eslint-disable wpcalypso/jsx-classname-namespace */
const [ readerOnboardingIsRendered, setReaderOnboardingIsRendered ] = useState( false );

return (
<>
<Stream
Expand All @@ -29,13 +30,13 @@ function FollowingStream( { ...props } ) {
'reader-dual-column': props.width > WIDE_DISPLAY_CUTOFF,
} ) }
/>
{ ! config.isEnabled( 'reader/onboarding' ) && <FollowingIntro /> }
{ config.isEnabled( 'reader/onboarding' ) && <ReaderOnboarding /> }

<ReaderOnboarding onRender={ setReaderOnboardingIsRendered } />
{ ! readerOnboardingIsRendered && <FollowingIntro /> }
</Stream>
<AsyncLoad require="calypso/lib/analytics/track-resurrections" placeholder={ null } />
</>
);
/* eslint-enable wpcalypso/jsx-classname-namespace */
}

export default SuggestionProvider( withDimensions( FollowingStream ) );
18 changes: 15 additions & 3 deletions client/reader/onboarding/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { recordTracksEvent } from '@automattic/calypso-analytics';
import config from '@automattic/calypso-config';
import { CircularProgressBar } from '@automattic/components';
import { Checklist, ChecklistItem, Task } from '@automattic/launchpad';
import { translate } from 'i18n-calypso';
Expand All @@ -7,22 +8,33 @@ import { READER_ONBOARDING_PREFERENCE_KEY } from 'calypso/reader/onboarding/cons
import InterestsModal from 'calypso/reader/onboarding/interests-modal';
import SubscribeModal from 'calypso/reader/onboarding/subscribe-modal';
import { useSelector } from 'calypso/state';
import { getCurrentUserDate } from 'calypso/state/current-user/selectors';
import { getPreference, hasReceivedRemotePreferences } from 'calypso/state/preferences/selectors';
import { getReaderFollowedTags } from 'calypso/state/reader/tags/selectors';

import './style.scss';

const ReaderOnboarding = () => {
const ReaderOnboarding = ( { onRender }: { onRender?: ( shown: boolean ) => void } ) => {
const [ isInterestsModalOpen, setIsInterestsModalOpen ] = useState( false );
const [ isDiscoverModalOpen, setIsDiscoverModalOpen ] = useState( false );
const followedTags = useSelector( getReaderFollowedTags );
const hasCompletedOnboarding = useSelector( ( state ) =>
getPreference( state, READER_ONBOARDING_PREFERENCE_KEY )
);
const preferencesLoaded = useSelector( hasReceivedRemotePreferences );
const userRegistrationDate = useSelector( getCurrentUserDate );

// Don't render anything until preferences are loaded or if onboarding is completed.
if ( ! preferencesLoaded || hasCompletedOnboarding ) {
const shouldShowOnboarding =
config.isEnabled( 'reader/onboarding' ) &&
preferencesLoaded &&
! hasCompletedOnboarding &&
userRegistrationDate &&
new Date( userRegistrationDate ) >= new Date( '2024-10-01T00:00:00Z' );

// Notify the parent component if onboarding will render.
onRender?.( shouldShowOnboarding );

if ( ! shouldShowOnboarding ) {
return null;
}

Expand Down
Loading