From e4d95cb31d7dc7a79995eee8f85f17c9a61529c2 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Sat, 14 Dec 2024 14:19:23 +0100 Subject: [PATCH] feat(android): properly disable service worker for android as it does not always work --- src/app/app.module.ts | 6 +++++- src/main.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index eda57cdc633..2f145fa7fd4 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -56,6 +56,7 @@ import { CalendarIntegrationModule } from './features/calendar-integration/calen import { ShepherdComponent } from './features/shepherd/shepherd.component'; import { CdkDropListGroup } from '@angular/cdk/drag-drop'; import { IssuePanelModule } from './features/issue-panel/issue-panel.module'; +import { IS_ANDROID_WEB_VIEW } from './util/is-android-web-view'; // NOTE: export required for aot to work export const createTranslateLoader = (http: HttpClient): TranslateHttpLoader => @@ -131,7 +132,10 @@ export const createTranslateLoader = (http: HttpClient): TranslateHttpLoader => validationMessages: [{ name: 'pattern', message: 'Invalid input' }], }), ServiceWorkerModule.register('ngsw-worker.js', { - enabled: !IS_ELECTRON && (environment.production || environment.stage), + enabled: + !IS_ELECTRON && + !IS_ANDROID_WEB_VIEW && + (environment.production || environment.stage), // Register the ServiceWorker as soon as the application is stable // or after 30 seconds (whichever comes first). registrationStrategy: 'registerWhenStable:30000', diff --git a/src/main.ts b/src/main.ts index 573c4a7f6bc..fd043e303ba 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,7 +31,7 @@ platformBrowserDynamic() ) { console.log('Registering Service worker'); return navigator.serviceWorker.register('ngsw-worker.js'); - } else if ('serviceWorker' in navigator && IS_ELECTRON) { + } else if ('serviceWorker' in navigator && (IS_ELECTRON || IS_ANDROID_WEB_VIEW)) { navigator.serviceWorker .getRegistrations() .then((registrations) => {