From 1dfa6ec7f19549a28c7c72fa4d512e72c7c35f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 17 Jan 2023 14:20:26 -0500 Subject: [PATCH 1/2] fix(portal): error on non pwa app on ngsw registration --- src/app/app.module.ts | 2 +- src/app/services/pwa.service.ts | 6 +++++- src/environments/environment.github.ts | 11 +++++++++-- src/environments/environment.prod.ts | 10 +++++++++- src/environments/environment.pwa.ts | 7 ++++++- src/environments/environment.ts | 10 +++++++++- 6 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index ffe319d02..1f2184a83 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -71,7 +71,7 @@ export const defaultTooltipOptions: MatTooltipDefaultOptions = { HammerModule, HeaderModule, FooterModule, - ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production, registrationStrategy: 'registerWithDelay:5000' }) + ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.igo.app.pwa.enabled, registrationStrategy: 'registerWithDelay:5000' }) ], providers: [ provideConfigOptions({ diff --git a/src/app/services/pwa.service.ts b/src/app/services/pwa.service.ts index db795e7fa..7557dce78 100644 --- a/src/app/services/pwa.service.ts +++ b/src/app/services/pwa.service.ts @@ -54,7 +54,11 @@ export class PwaService { } public async initPwaPrompt(): Promise { - if (this.configService.getConfig('app') && this.configService.getConfig('app.promotePwa')) { + if ( + this.configService.getConfig('app') && + this.configService.getConfig('app.pwa') && + this.configService.getConfig('app.pwa.enabled') && + this.configService.getConfig('app.pwa.promote')) { if (!this.platform.IOS) { window.addEventListener('beforeinstallprompt', (event: any) => { event.preventDefault(); diff --git a/src/environments/environment.github.ts b/src/environments/environment.github.ts index 9818aa5e5..ad0324183 100644 --- a/src/environments/environment.github.ts +++ b/src/environments/environment.github.ts @@ -12,7 +12,10 @@ interface Environment { igo: { app: { forceCoordsNA: boolean; - promotePwa?: boolean; + pwa?: { + enabled?: boolean; + promote?: boolean; + } }; catalog?: CatalogServiceOptions; importExport?: ImportExportServiceOptions; @@ -38,7 +41,11 @@ export const environment: Environment = { production: true, igo: { app: { - forceCoordsNA: false + forceCoordsNA: false, + pwa: { + enabled: false, + promote: false + } }, catalog: { sources: [ diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 4141514cf..5a3d9c46d 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -13,6 +13,10 @@ export interface Environment { igo: { app: { forceCoordsNA: boolean; + pwa?: { + enabled?: boolean; + promote?: boolean; + } }; importExport?: ImportExportServiceOptions; language?: LanguageOptions; @@ -39,7 +43,11 @@ export const environment: Environment = { production: true, igo: { app: { - forceCoordsNA: true + forceCoordsNA: true, + pwa: { + enabled: false, + promote: false + } }, importExport: { url: '/apis/ogre' diff --git a/src/environments/environment.pwa.ts b/src/environments/environment.pwa.ts index 237722c96..58f168773 100644 --- a/src/environments/environment.pwa.ts +++ b/src/environments/environment.pwa.ts @@ -1,4 +1,9 @@ import { environment as prodEnv } from './environment.github'; -prodEnv.igo.app.promotePwa = true; + +if (!prodEnv.igo.app.pwa) { + prodEnv.igo.app.pwa = {}; +} +prodEnv.igo.app.pwa.enabled = true; +prodEnv.igo.app.pwa.promote = true; export const environment = prodEnv; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 1af34757a..572a0d2ff 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -20,6 +20,10 @@ interface Environment { igo: { app: { forceCoordsNA: boolean; + pwa?: { + enabled?: boolean; + promote?: boolean; + } }; auth?: AuthOptions; storage: AuthStorageOptions @@ -49,7 +53,11 @@ export const environment: Environment = { production: false, igo: { app: { - forceCoordsNA: true + forceCoordsNA: true, + pwa: { + enabled: false, + promote: false + } }, auth: { url: '/apis/users', From 2b2ccdd3b99a266ed0e798a41ebc1f6a875cdff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 17 Jan 2023 14:26:39 -0500 Subject: [PATCH 2/2] lint --- src/app/app.module.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1f2184a83..9b453c0ae 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -71,7 +71,10 @@ export const defaultTooltipOptions: MatTooltipDefaultOptions = { HammerModule, HeaderModule, FooterModule, - ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.igo.app.pwa.enabled, registrationStrategy: 'registerWithDelay:5000' }) + ServiceWorkerModule.register('ngsw-worker.js', { + enabled: environment.igo.app.pwa.enabled, + registrationStrategy: 'registerWithDelay:5000' + }) ], providers: [ provideConfigOptions({