diff --git a/package.json b/package.json index d35bcf0..e03bdbb 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "build": "ng build --target=development --env=dev", "build-prod": "ng build --target=production --env=prod", "build-prod-with-source-maps": "ng build --target=production --env=prod -sm", + "ngsw-config": "ngsw-config dist src/ngsw-config.json", "start": "ng serve --target=development --env=dev", "start-sw": "http-server dist/ -p 4200 -o", "start-prod": "ng serve --target=production --env=prod", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ed9bd3e..96447ea 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -6,6 +6,7 @@ import {NavService} from './nav.service'; import {GoogleAnalyticsService} from './google-analytics.service'; import {isPlatformBrowser} from '@angular/common'; import {filter} from 'rxjs/operators'; +import {Observable} from 'rxjs/Observable'; @Component({ selector: 'app-root', @@ -64,6 +65,7 @@ export class AppComponent implements OnInit, AfterViewInit { this.navService.appDrawer = this.appDrawer; } + logout() { this.navService.closeNav(); this.usersService.logout(); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 689579d..cf830d8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -75,7 +75,8 @@ import {PageNotFoundComponent} from './page-not-found/page-not-found.component'; MatRippleModule, FlexLayoutModule, AppRoutingModule, - ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}) + ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production, + registrationStrategy: environment.serviceWorkerStrategy}) ], providers: [ ApiService, diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index bafaf49..88cfd7e 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,4 +1,14 @@ // For deployment to production only. +import {Observable} from 'rxjs/Observable'; + +export function getServiceWorkerObservable() { + return new Observable(observer => { + setTimeout(() => { + observer.next(); + }, 10000); + }); +} + export const environment = { production: true, firebaseConfig: { @@ -10,5 +20,9 @@ export const environment = { messagingSenderId: '1003263481418' }, googleAnalyticsTrackingId: '', - mapsApiKey: 'AIzaSyCG5P0ZrbWcC212QZsEebyyGwj2KRgs700' + mapsApiKey: 'AIzaSyCG5P0ZrbWcC212QZsEebyyGwj2KRgs700', + serviceWorkerStrategy: 'registerDelay:5000' + // serviceWorkerStrategy: 'registerImmediately' + // serviceWorkerStrategy: 'registerWhenStable' + // serviceWorkerStrategy: getServiceWorkerObservable }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 017b1ca..682f447 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -10,5 +10,6 @@ export const environment = { messagingSenderId: '1003263481418' }, googleAnalyticsTrackingId: '', - mapsApiKey: 'AIzaSyCG5P0ZrbWcC212QZsEebyyGwj2KRgs700' + mapsApiKey: 'AIzaSyCG5P0ZrbWcC212QZsEebyyGwj2KRgs700', + serviceWorkerStrategy: 'registerImmediately' };