refactor(web): dependency management (#2386)

This commit is contained in:
Mo
2023-08-05 12:48:39 -05:00
committed by GitHub
parent b07da5b663
commit d8d4052a52
274 changed files with 4065 additions and 3873 deletions

View File

@@ -1,28 +1,12 @@
import { WebApplication } from '@/Application/WebApplication'
import { IsTabletOrMobileScreen } from '@/Application/UseCase/IsTabletOrMobileScreen'
import { useApplication } from '@/Components/ApplicationProvider'
import { debounce, isMobileScreen, isTabletOrMobileScreen, isTabletScreen } from '@/Utils'
import { useEffect, useState } from 'react'
export function getIsTabletOrMobileScreen(application: WebApplication) {
const isNativeMobile = application.isNativeMobileWeb()
const isTabletOrMobile = isTabletOrMobileScreen() || isNativeMobile
const isTablet = isTabletScreen() || (isNativeMobile && !isMobileScreen())
const isMobile = isMobileScreen() || (isNativeMobile && !isTablet)
if (isTablet && isMobile) {
throw Error('isTablet and isMobile cannot both be true')
}
return {
isTabletOrMobile,
isTablet,
isMobile,
}
}
import { debounce } from '@/Utils'
import { useEffect, useMemo, useState } from 'react'
export default function useIsTabletOrMobileScreen() {
const [_windowSize, setWindowSize] = useState(0)
const application = useApplication()
const usecase = useMemo(() => new IsTabletOrMobileScreen(application.environment), [application])
useEffect(() => {
const handleResize = debounce(() => {
@@ -37,5 +21,6 @@ export default function useIsTabletOrMobileScreen() {
}
}, [])
return getIsTabletOrMobileScreen(application)
const isTabletOrMobileScreen = usecase.execute().getValue()
return isTabletOrMobileScreen
}