feat(mobile): add setting to always open web view on launch (#1500)

This commit is contained in:
Aman Harwara
2022-09-09 13:32:23 +05:30
committed by GitHub
parent e2715709d4
commit 320fc3fd96
8 changed files with 64 additions and 16 deletions

View File

@@ -33,6 +33,7 @@ export function environmentFromString(string: string) {
web: Environment.Web,
desktop: Environment.Desktop,
mobile: Environment.Mobile,
nativeMobileWeb: Environment.NativeMobileWeb,
}
return map[string]
}
@@ -42,6 +43,7 @@ export function environmentToString(environment: Environment) {
[Environment.Web]: 'web',
[Environment.Desktop]: 'desktop',
[Environment.Mobile]: 'mobile',
[Environment.NativeMobileWeb]: 'native-mobile-web',
}
return map[environment]
}

View File

@@ -291,11 +291,15 @@ export class SNComponentManager
}
const isWeb = this.environment === Environment.Web
const isMobileWebView = this.environment === Environment.NativeMobileWeb
if (nativeFeature) {
if (!isWeb) {
if (!isWeb && !isMobileWebView) {
throw Error('Mobile must override urlForComponent to handle native paths')
}
const baseUrlRequiredForThemesInsideEditors = window.location.origin
let baseUrlRequiredForThemesInsideEditors = window.location.origin
if (isMobileWebView) {
baseUrlRequiredForThemesInsideEditors = window.location.href.split('/index.html')[0]
}
return `${baseUrlRequiredForThemesInsideEditors}/components/assets/${component.identifier}/${nativeFeature.index_path}`
}