Permalink
Browse files

perf(build-details): clear update times interval

  • Loading branch information...
jkuri committed Aug 20, 2017
1 parent 3dbf648 commit 22c8ea2445673465cfa79a29bd26ae2d0d570900
Showing with 18 additions and 3 deletions.
  1. +18 −3 src/app/components/app-build-details/app-build-details.component.ts
@@ -21,6 +21,7 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy {
processingBuild: boolean;
approximatelyRemainingTime: string;
tag: string = null;
updateInterval: any;

constructor(
private socketService: SocketService,
@@ -54,9 +55,7 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy {
}

this.status = this.getBuildStatus();

this.updateJobTimes();
setInterval(() => this.updateJobTimes(), 1000);
this.startUpdating();

this.socketService.outputEvents
.filter(event => event.type === 'process')
@@ -93,6 +92,22 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.document.getElementById('favicon').setAttribute('href', 'images/favicon.png');
this.titleService.setTitle('Abstruse CI');
this.stopUpdating();
}

startUpdating(): void {
if (this.updateInterval) {
clearInterval(this.updateInterval);
}

this.updateJobTimes();
this.updateInterval = setInterval(() => this.updateJobTimes(), 1000);
}

stopUpdating(): void {
if (this.updateInterval) {
clearInterval(this.updateInterval);
}
}

updateJobTimes(): void {

0 comments on commit 22c8ea2

Please sign in to comment.