Clear interval on destroy and remove commented code

This commit is contained in:
natsoni
2024-07-13 18:45:18 +09:00
parent 5e8b5e75d8
commit 9ac45a6cc3
2 changed files with 6 additions and 4 deletions

View File

@@ -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);
}
}