fix: on mobile open links from editor in external browser (#1860)

This commit is contained in:
Aman Harwara
2022-10-25 21:38:29 +05:30
committed by GitHub
parent ca7455a854
commit d9db73ea05
14 changed files with 99 additions and 62 deletions

View File

@@ -1,3 +1,7 @@
/**
* @jest-environment jsdom
*/
import { SNLog } from './../Log'
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { AlertService, DeviceInterface, namespacedKey, RawStorageKey } from '@standardnotes/services'

View File

@@ -940,7 +940,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
}
isNativeMobileWeb() {
return this.environment === Environment.NativeMobileWeb
return this.environment === Environment.Mobile
}
getDeinitMode(): DeinitMode {
@@ -1353,10 +1353,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
}
private createComponentManager() {
const MaybeSwappedComponentManager = this.getClass<typeof InternalServices.SNComponentManager>(
InternalServices.SNComponentManager,
)
this.componentManagerService = new MaybeSwappedComponentManager(
this.componentManagerService = new InternalServices.SNComponentManager(
this.itemManager,
this.syncService,
this.featuresService,
@@ -1365,6 +1362,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
this.environment,
this.platform,
this.internalEventBus,
this.deviceInterface,
)
this.services.push(this.componentManagerService)
}
@@ -1647,13 +1645,4 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
this.statusService = new ExternalServices.StatusService(this.internalEventBus)
this.services.push(this.statusService)
}
private getClass<T>(base: T) {
const swapClass = this.options.swapClasses?.find((candidate) => candidate.swap === base)
if (swapClass) {
return swapClass.with as T
} else {
return base
}
}
}

View File

@@ -10,14 +10,6 @@ export interface ApplicationDisplayOptions {
}
export interface ApplicationOptionalConfiguratioOptions {
/**
* Gives consumers the ability to provide their own custom
* subclass for a service. swapClasses should be an array of key/value pairs
* consisting of keys 'swap' and 'with'. 'swap' is the base class you wish to replace,
* and 'with' is the custom subclass to use.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
swapClasses?: { swap: any; with: any }[]
/**
* URL for WebSocket providing permissions and roles information.
*/

View File

@@ -28,22 +28,11 @@ export function platformToString(platform: Platform) {
return map[platform]
}
export function environmentFromString(string: string) {
const map: Record<string, Environment> = {
web: Environment.Web,
desktop: Environment.Desktop,
mobile: Environment.Mobile,
nativeMobileWeb: Environment.NativeMobileWeb,
}
return map[string]
}
export function environmentToString(environment: Environment) {
const map = {
[Environment.Web]: 'web',
[Environment.Desktop]: 'desktop',
[Environment.Mobile]: 'mobile',
[Environment.NativeMobileWeb]: 'native-mobile-web',
[Environment.Mobile]: 'native-mobile-web',
}
return map[environment]
}