1- import { useState , useEffect } from 'react'
1+ import React , { Suspense , useEffect , useLayoutEffect , useState } from 'react'
2+ import 'react-contexify/dist/ReactContexify.css'
23import 'src/assets/App.css'
34import { Footer , Header } from 'src/components/Layout'
45import { BookmarksSidebar } from 'src/features/bookmarks'
56import { MarketingBanner } from 'src/features/MarketingBanner'
6- import { ScrollCardsNavigator } from './components/Layout'
7- import { AppContentLayout } from './components/Layout'
8- import 'react-contexify/dist/ReactContexify.css'
9- import { setupAnalytics , trackPageView , setupIdentification } from 'src/lib/analytics'
7+ import { setupAnalytics , setupIdentification , trackPageView } from 'src/lib/analytics'
8+ import { useUserPreferences } from 'src/stores/preferences'
9+ import { diffBetweenTwoDatesInDays } from 'src/utils/DateUtils'
10+ import { AppContentLayout , ScrollCardsNavigator } from './components/Layout'
11+ import { isWebOrExtensionVersion } from './utils/Environment'
12+ import { getAppVersion } from './utils/Os'
13+
14+ const OnboardingModal = React . lazy ( ( ) =>
15+ import ( 'src/features/onboarding' ) . then ( ( module ) => ( { default : module . OnboardingModal } ) )
16+ )
1017
1118function App ( ) {
1219 const [ showSideBar , setShowSideBar ] = useState ( false )
1320 const [ showSettings , setShowSettings ] = useState ( false )
21+ const [ showOnboarding , setShowOnboarding ] = useState ( true )
22+ const { onboardingCompleted, firstSeenDate, markOnboardingAsCompleted } = useUserPreferences ( )
23+
24+ useLayoutEffect ( ( ) => {
25+ if ( ! onboardingCompleted && getAppVersion ( ) <= '1.15.9' ) {
26+ const usageDays = diffBetweenTwoDatesInDays ( firstSeenDate , Date . now ( ) )
27+ if ( usageDays > 0 ) {
28+ markOnboardingAsCompleted ( null )
29+ }
30+ }
31+ // eslint-disable-next-line react-hooks/exhaustive-deps
32+ } , [ onboardingCompleted , firstSeenDate ] )
1433
1534 useEffect ( ( ) => {
1635 setupAnalytics ( )
@@ -21,7 +40,16 @@ function App() {
2140 return (
2241 < >
2342 < MarketingBanner />
43+
2444 < div className = "App" >
45+ { ! onboardingCompleted && isWebOrExtensionVersion ( ) === 'extension' && (
46+ < Suspense fallback = { null } >
47+ < OnboardingModal
48+ showOnboarding = { showOnboarding }
49+ setShowOnboarding = { setShowOnboarding }
50+ />
51+ </ Suspense >
52+ ) }
2553 < Header
2654 setShowSideBar = { setShowSideBar }
2755 showSideBar = { showSideBar }
0 commit comments