We are showing a bottom sheet when there is a new update available for our Angular PWA. It is inside the SwUpdate.available method. The SwUpdate.available only gets triggered when we run the build command in the server. If we run the build command in local & upload the files to the server, nothing happens. As our server has less RAM, the build command fails most of the time on the server.
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
constructor(
private swUpdate: SwUpdate,
private _bottomSheet: MatBottomSheet,
) {
this.checkForUpdates();
}
ngOnInit() {}
checkForUpdates() {
this.swUpdate.available.subscribe(event => {
this.swUpdate.activateUpdate().then(() => {
this.openBottomSheet();
});
});
}
openBottomSheet(): void {
this._bottomSheet.open(UpdateBottomSheetComponent);
}
}