Clear interval on destroy and remove commented code
This commit is contained in:
@@ -20,6 +20,7 @@ export class AccelerationTimelineComponent implements OnInit, OnChanges {
|
||||
now: number;
|
||||
accelerateRatio: number;
|
||||
useAbsoluteTime: boolean = false;
|
||||
interval: number;
|
||||
|
||||
constructor() {}
|
||||
|
||||
@@ -28,7 +29,7 @@ export class AccelerationTimelineComponent implements OnInit, OnChanges {
|
||||
this.now = Math.floor(new Date().getTime() / 1000);
|
||||
this.useAbsoluteTime = this.tx.status.block_time < this.now - 7 * 24 * 3600;
|
||||
|
||||
window.setInterval(() => {
|
||||
this.interval = window.setInterval(() => {
|
||||
this.now = Math.floor(new Date().getTime() / 1000);
|
||||
this.useAbsoluteTime = this.tx.status.block_time < this.now - 7 * 24 * 3600;
|
||||
}, 60000);
|
||||
@@ -47,4 +48,8 @@ export class AccelerationTimelineComponent implements OnInit, OnChanges {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
clearInterval(this.interval);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user