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,26 +1,29 @@
import { WebApplication } from '@/Application/WebApplication'
import { downloadBlobOnAndroid } from '@/NativeMobileWeb/DownloadBlobOnAndroid'
import { shareBlobOnMobile } from '@/NativeMobileWeb/ShareBlobOnMobile'
import { Platform } from '@standardnotes/snjs'
import { MobileDeviceInterface, Platform } from '@standardnotes/snjs'
import { ArchiveManager } from '@standardnotes/ui-services'
export const downloadOrShareBlobBasedOnPlatform = async (
application: WebApplication,
blob: Blob,
filename: string,
showToastOnAndroid = true,
) => {
if (!application.isNativeMobileWeb()) {
application.getArchiveService().downloadData(blob, filename)
export const downloadOrShareBlobBasedOnPlatform = async (dto: {
archiveService: ArchiveManager
platform: Platform
mobileDevice: MobileDeviceInterface | undefined
blob: Blob
filename: string
isNativeMobileWeb: boolean
showToastOnAndroid?: boolean
}) => {
if (!dto.isNativeMobileWeb) {
dto.archiveService.downloadData(dto.blob, dto.filename)
return
}
if (application.platform === Platform.Ios) {
void shareBlobOnMobile(application, blob, filename)
if (dto.mobileDevice && dto.platform === Platform.Ios) {
void shareBlobOnMobile(dto.mobileDevice, dto.isNativeMobileWeb, dto.blob, dto.filename)
return
}
if (application.platform === Platform.Android) {
void downloadBlobOnAndroid(application, blob, filename, showToastOnAndroid)
if (dto.mobileDevice && dto.platform === Platform.Android) {
void downloadBlobOnAndroid(dto.mobileDevice, dto.blob, dto.filename, dto.showToastOnAndroid ?? true)
return
}
}

View File

@@ -1,24 +0,0 @@
import { Environment } from '@standardnotes/snjs'
import { WebApplicationInterface } from '@standardnotes/ui-services'
export async function openSubscriptionDashboard(application: WebApplicationInterface) {
const token = await application.getNewSubscriptionToken()
if (!token) {
return
}
const url = `${window.dashboardUrl}?subscription_token=${token}`
if (application.device.environment === Environment.Mobile) {
application.device.openUrl(url)
return
}
if (application.device.environment === Environment.Desktop) {
window.open(url, '_blank')
return
}
const windowProxy = window.open('', '_blank')
;(windowProxy as WindowProxy).location = url
}

View File

@@ -2,6 +2,7 @@ import { DeviceInterface, MobileDeviceInterface, Platform, platformFromString }
import { IsDesktopPlatform, IsWebPlatform } from '@/Constants/Version'
import { EMAIL_REGEX } from '../Constants/Constants'
import { MutuallyExclusiveMediaQueryBreakpoints } from '@/Hooks/useMediaQuery'
import { isIOS } from '@standardnotes/ui-services'
declare const process: {
env: {
@@ -176,14 +177,6 @@ export const convertStringifiedBooleanToBoolean = (value: string) => {
return value !== 'false'
}
// https://stackoverflow.com/questions/9038625/detect-if-device-is-ios/9039885#9039885
export const isIOS = () =>
(/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) ||
(navigator.userAgent.includes('Mac') && 'ontouchend' in document && navigator.maxTouchPoints > 1) ||
window.platform === Platform.Ios
export const isAndroid = () => navigator.userAgent.toLowerCase().includes('android')
// https://stackoverflow.com/a/57527009/2504429
export const disableIosTextFieldZoom = () => {
const addMaximumScaleToMetaViewport = () => {