Skip to content

Commit

Permalink
perf(build-details): clear update times interval
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Aug 20, 2017
1 parent 3dbf648 commit 22c8ea2
Showing 1 changed file with 18 additions and 3 deletions.
Expand Up @@ -21,6 +21,7 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy {
processingBuild: boolean;
approximatelyRemainingTime: string;
tag: string = null;
updateInterval: any;

constructor(
private socketService: SocketService,
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 22c8ea2

Please sign in to comment.