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
@@ -0,0 +1,32 @@
import { isMobileScreen, isTabletOrMobileScreen, isTabletScreen } from '@/Utils'
import { Environment, Result, SyncUseCaseInterface } from '@standardnotes/snjs'
import { IsNativeMobileWeb } from '@standardnotes/ui-services'
type ReturnType = {
isTabletOrMobile: boolean
isTablet: boolean
isMobile: boolean
}
export class IsTabletOrMobileScreen implements SyncUseCaseInterface<ReturnType> {
private _isNativeMobileWeb = new IsNativeMobileWeb(this.environment)
constructor(private environment: Environment) {}
execute(): Result<ReturnType> {
const isNativeMobile = this._isNativeMobileWeb.execute().getValue()
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 Result.ok({
isTabletOrMobile,
isTablet,
isMobile,
})
}
}