From 1d22d2514f7be14d51ed2ab78e13df5da2646546 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 18 Jan 2021 11:16:37 +0100 Subject: Fix service worker --- client/src/app/app.module.ts | 5 ++++- client/src/main.ts | 5 ----- client/src/manifest.webmanifest | 8 ++++---- client/src/ngsw-config.json | 1 + 4 files changed, 9 insertions(+), 10 deletions(-) (limited to 'client') diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 98dec4244..f790a6848 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -1,7 +1,9 @@ import 'focus-visible' +import { environment } from 'src/environments/environment' import { APP_BASE_HREF, registerLocaleData } from '@angular/common' import { NgModule } from '@angular/core' import { BrowserModule } from '@angular/platform-browser' +import { ServiceWorkerModule } from '@angular/service-worker' import { ServerService } from '@app/core' import localeOc from '@app/helpers/locales/oc' import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' @@ -11,7 +13,7 @@ import { CoreModule } from './core' import { EmptyComponent } from './empty.component' import { HeaderComponent, SearchTypeaheadComponent, SuggestionComponent } from './header' import { HighlightPipe } from './header/highlight.pipe' -import { NotificationComponent, LanguageChooserComponent, MenuComponent } from './menu' +import { LanguageChooserComponent, MenuComponent, NotificationComponent } from './menu' import { ConfirmComponent } from './modal/confirm.component' import { CustomModalComponent } from './modal/custom-modal.component' import { InstanceConfigWarningModalComponent } from './modal/instance-config-warning-modal.component' @@ -49,6 +51,7 @@ registerLocaleData(localeOc, 'oc') imports: [ BrowserModule, + ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }), CoreModule, SharedMainModule, diff --git a/client/src/main.ts b/client/src/main.ts index 99976a3f7..84c82203d 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -11,11 +11,6 @@ if (environment.production) { const bootstrap = () => platformBrowserDynamic() .bootstrapModule(AppModule) .then(bootstrapModule => { - if ('serviceWorker' in navigator && environment.production) { - navigator.serviceWorker.register('/ngsw-worker.js') - .catch(err => console.error('Cannot register service worker.', err)) - } - if (!environment.production) { const applicationRef = bootstrapModule.injector.get(ApplicationRef) const componentRef = applicationRef.components[0] diff --git a/client/src/manifest.webmanifest b/client/src/manifest.webmanifest index 851e098a8..6e62856cd 100644 --- a/client/src/manifest.webmanifest +++ b/client/src/manifest.webmanifest @@ -1,4 +1,7 @@ { + "name": "PeerTube", + "short_name": "PeerTube", + "start_url": "/", "background_color": "#fff", "theme_color": "#fff", "description": "A federated video streaming platform using P2P", @@ -40,8 +43,5 @@ "sizes": "512x512", "type": "image/png" } - ], - "name": "PeerTube", - "short_name": "PeerTube", - "start_url": "/" + ] } diff --git a/client/src/ngsw-config.json b/client/src/ngsw-config.json index d68db79d0..af7554c00 100644 --- a/client/src/ngsw-config.json +++ b/client/src/ngsw-config.json @@ -1,4 +1,5 @@ { + "$schema": "../node_modules/@angular/service-worker/config/schema.json", "index": "/index.html", "assetGroups": [ { -- cgit v1.2.3