Stop making unnecessary calls to the update service

This commit is contained in:
Jamie 2017-12-15 08:46:46 +00:00
commit 52a22b3a60

View file

@ -21,6 +21,8 @@ export class AppComponent implements OnInit {
public updateAvailable: boolean; public updateAvailable: boolean;
public currentUrl: string; public currentUrl: string;
private checkedForUpdate: boolean;
constructor(public notificationService: NotificationService, constructor(public notificationService: NotificationService,
public authService: AuthService, public authService: AuthService,
private readonly router: Router, private readonly router: Router,
@ -47,7 +49,8 @@ export class AppComponent implements OnInit {
this.user = this.authService.claims(); this.user = this.authService.claims();
this.showNav = this.authService.loggedIn(); this.showNav = this.authService.loggedIn();
if (this.user !== null && this.user.name) { if (this.user !== null && this.user.name && !this.checkedForUpdate) {
this.checkedForUpdate = true;
this.jobService.getCachedUpdate().subscribe(x => { this.jobService.getCachedUpdate().subscribe(x => {
this.updateAvailable = x; this.updateAvailable = x;
}); });