Skip to content

Commit

Permalink
feat(android): properly disable service worker for android as it does…
Browse files Browse the repository at this point in the history
… not always work
  • Loading branch information
johannesjo committed Dec 14, 2024
1 parent 16628a3 commit e4d95cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit e4d95cb

Please sign in to comment.