Update SW cache

This commit is contained in:
Zakary Timson 2018-08-08 14:43:43 -04:00
parent 6565178ecd
commit 538c585cc1
2 changed files with 59 additions and 53 deletions

View File

@ -7,6 +7,7 @@ import {LoginComponent} from './login/login.component';
import { LocalStorage } from 'webstorage-decorators';
import { AppStore } from './app.store';
import { AngularFireAuth } from '../../node_modules/angularfire2/auth';
import { SwUpdate } from '../../node_modules/@angular/service-worker';
@Component({
selector: 'app-root',
@ -19,10 +20,15 @@ export class AppComponent implements OnInit {
constructor(
private router: Router,
private dialog: MatDialog,
private updates: SwUpdate,
public electron: ElectronService,
public store: AppStore,
public afAuth: AngularFireAuth
) {}
) {
updates.available.subscribe(event => {
if (event.current != event.available) updates.activateUpdate().then(() => document.location.reload());
});
}
cartAdd(id: string, item: string, price: number, currency: 'CAD' | 'USD', quantity: number) {
this.cart = [{ id: id, item: item, price: Number(price), currency: currency, quantity: Number(quantity) }].concat(

View File

@ -72,7 +72,7 @@ import {SlideshowModule} from 'ng-simple-slideshow';
{ path: 'store', component: CategoriesComponent },
{ path: '**', component: HomeComponent }
]),
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: false}),
ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production }),
SlideshowModule
],
providers: [AppStore],