Don't show negative timespans on timeline

This commit is contained in:
natsoni 2024-09-23 14:47:57 +02:00
parent 05e88a25be
commit 2a9346f695
No known key found for this signature in database
GPG Key ID: C65917583181743B
2 changed files with 13 additions and 8 deletions

View File

@ -38,7 +38,7 @@
<div class="node-spacer"></div>
<div class="interval">
<div class="interval-time">
<app-time [time]="acceleratedAt - transactionTime"></app-time>
<app-time [time]="firstSeenToAccelerated"></app-time>
</div>
</div>
<div class="node-spacer"></div>
@ -46,7 +46,7 @@
<div class="interval-time">
@if (tx.status.confirmed) {
<div class="interval-time">
<app-time [time]="tx.status.block_time - acceleratedAt"></app-time>
<app-time [time]="acceleratedToMined"></app-time>
</div>
} @else if (standardETA && !tx.status.confirmed) {
<!-- ~<app-time [time]="standardETA / 1000 - now"></app-time> -->

View File

@ -24,6 +24,8 @@ export class AccelerationTimelineComponent implements OnInit, OnChanges {
accelerateRatio: number;
useAbsoluteTime: boolean = false;
interval: number;
firstSeenToAccelerated: number;
acceleratedToMined: number;
tooltipPosition = null;
hoverInfo: any = null;
@ -35,8 +37,6 @@ export class AccelerationTimelineComponent implements OnInit, OnChanges {
ngOnInit(): void {
this.acceleratedAt = this.tx.acceleratedAt ?? new Date().getTime() / 1000;
this.now = Math.floor(new Date().getTime() / 1000);
this.useAbsoluteTime = this.tx.status.block_time < this.now - 7 * 24 * 3600;
this.miningService.getPools().subscribe(pools => {
for (const pool of pools) {
@ -44,10 +44,8 @@ export class AccelerationTimelineComponent implements OnInit, OnChanges {
}
});
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);
this.updateTimes();
this.interval = window.setInterval(this.updateTimes.bind(this), 60000);
}
ngOnChanges(changes): void {
@ -64,6 +62,13 @@ export class AccelerationTimelineComponent implements OnInit, OnChanges {
// }
}
updateTimes(): void {
this.now = Math.floor(new Date().getTime() / 1000);
this.useAbsoluteTime = this.tx.status.block_time < this.now - 7 * 24 * 3600;
this.firstSeenToAccelerated = Math.max(0, this.acceleratedAt - this.transactionTime);
this.acceleratedToMined = Math.max(0, this.tx.status.block_time - this.acceleratedAt);
}
ngOnDestroy(): void {
clearInterval(this.interval);
}