Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(portal): error on non pwa app on ngsw registration #897

Merged
merged 2 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ 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({
Expand Down
6 changes: 5 additions & 1 deletion src/app/services/pwa.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export class PwaService {
}

public async initPwaPrompt(): Promise<any> {
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();
Expand Down
11 changes: 9 additions & 2 deletions src/environments/environment.github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ interface Environment {
igo: {
app: {
forceCoordsNA: boolean;
promotePwa?: boolean;
pwa?: {
enabled?: boolean;
promote?: boolean;
}
};
catalog?: CatalogServiceOptions;
importExport?: ImportExportServiceOptions;
Expand All @@ -38,7 +41,11 @@ export const environment: Environment = {
production: true,
igo: {
app: {
forceCoordsNA: false
forceCoordsNA: false,
pwa: {
enabled: false,
promote: false
}
},
catalog: {
sources: [
Expand Down
10 changes: 9 additions & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export interface Environment {
igo: {
app: {
forceCoordsNA: boolean;
pwa?: {
enabled?: boolean;
promote?: boolean;
}
};
importExport?: ImportExportServiceOptions;
language?: LanguageOptions;
Expand All @@ -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'
Expand Down
7 changes: 6 additions & 1 deletion src/environments/environment.pwa.ts
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 9 additions & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ interface Environment {
igo: {
app: {
forceCoordsNA: boolean;
pwa?: {
enabled?: boolean;
promote?: boolean;
}
};
auth?: AuthOptions;
storage: AuthStorageOptions
Expand Down Expand Up @@ -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',
Expand Down