11import React , { Suspense , useEffect , useLayoutEffect , useState } from 'react'
22import 'react-contexify/dist/ReactContexify.css'
33import 'src/assets/App.css'
4- import { Header , PausedAppContent } from 'src/components/Layout'
4+ import { DNDLayout , Header } from 'src/components/Layout'
55import { BookmarksSidebar } from 'src/features/bookmarks'
66import { MarketingBanner } from 'src/features/MarketingBanner'
77import { setupAnalytics , setupIdentification , trackPageView } from 'src/lib/analytics'
88import { useUserPreferences } from 'src/stores/preferences'
99import { diffBetweenTwoDatesInDays } from 'src/utils/DateUtils'
10- import { AppContentLayout , ScrollCardsNavigator } from './components/Layout'
10+ import { AppContentLayout } from './components/Layout'
1111import { isWebOrExtensionVersion } from './utils/Environment'
1212import { getAppVersion } from './utils/Os'
1313
1414const OnboardingModal = React . lazy ( ( ) =>
1515 import ( 'src/features/onboarding' ) . then ( ( module ) => ( { default : module . OnboardingModal } ) )
1616)
1717
18+ const intersectionOptions = {
19+ threshold : 0.5 ,
20+ }
21+
1822function App ( ) {
1923 const [ showSideBar , setShowSideBar ] = useState ( false )
2024 const [ showSettings , setShowSettings ] = useState ( false )
@@ -24,7 +28,7 @@ function App() {
2428 firstSeenDate,
2529 markOnboardingAsCompleted,
2630 maxVisibleCards,
27- pauseTo ,
31+ isPauseModeActive ,
2832 } = useUserPreferences ( )
2933
3034 useLayoutEffect ( ( ) => {
@@ -47,15 +51,34 @@ function App() {
4751 trackPageView ( 'home' )
4852 } , [ ] )
4953
50- const isAppPaused = Boolean ( pauseTo && pauseTo - new Date ( ) . getTime ( ) > 0 )
51- console . log ( 'pauseTo: ' , isAppPaused )
54+ let callback = ( entries ) => {
55+ entries . forEach ( ( entry ) => {
56+ if ( ! entry . isIntersecting ) {
57+ document . documentElement . classList . remove ( 'dndState' )
58+ } else {
59+ document . documentElement . classList . add ( 'dndState' )
60+ }
61+ } )
62+ }
63+
64+ useLayoutEffect ( ( ) => {
65+ let dndLayoutDiv = document . getElementsByClassName ( 'pauseContentWrapper' ) [ 0 ]
66+ let observer = new IntersectionObserver ( callback , intersectionOptions )
67+
68+ if ( dndLayoutDiv ) {
69+ observer . observe ( dndLayoutDiv )
70+ }
71+
72+ return ( ) => {
73+ observer . disconnect ( )
74+ }
75+ } , [ ] )
5276
5377 return (
5478 < >
5579 < MarketingBanner />
5680
5781 < div className = "App" >
58- < PausedAppContent isAppPaused = { isAppPaused } />
5982 { ! onboardingCompleted && isWebOrExtensionVersion ( ) === 'extension' && (
6083 < Suspense fallback = { null } >
6184 < OnboardingModal
@@ -70,8 +93,11 @@ function App() {
7093 showSettings = { showSettings }
7194 setShowSettings = { setShowSettings }
7295 />
73- < ScrollCardsNavigator />
74- < AppContentLayout setShowSettings = { setShowSettings } />
96+
97+ < div className = "layoutLayers hideScrollBar" >
98+ { isPauseModeActive ( ) && < DNDLayout /> }
99+ < AppContentLayout setShowSettings = { setShowSettings } />
100+ </ div >
75101 < BookmarksSidebar showSidebar = { showSideBar } onClose = { ( ) => setShowSideBar ( false ) } />
76102 </ div >
77103 </ >
0 commit comments