Show goggles badges on block overview tooltip
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Component, ElementRef, ViewChild, Input, OnChanges, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { Component, ElementRef, ViewChild, Input, OnChanges, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
|
||||
import { Position } from '../../components/block-overview-graph/sprite-types.js';
|
||||
import { Price } from '../../services/price.service';
|
||||
import { TransactionStripped } from '../../interfaces/node-api.interface.js';
|
||||
import { TransactionFlags } from '../../shared/filters.utils';
|
||||
import { Filter, FilterMode, TransactionFlags, toFilters } from '../../shared/filters.utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-block-overview-tooltip',
|
||||
@@ -15,6 +15,8 @@ export class BlockOverviewTooltipComponent implements OnChanges {
|
||||
@Input() clickable: boolean;
|
||||
@Input() auditEnabled: boolean = false;
|
||||
@Input() blockConversion: Price;
|
||||
@Input() filterFlags: bigint | null = null;
|
||||
@Input() filterMode: FilterMode = 'and';
|
||||
|
||||
txid = '';
|
||||
fee = 0;
|
||||
@@ -24,12 +26,16 @@ export class BlockOverviewTooltipComponent implements OnChanges {
|
||||
effectiveRate;
|
||||
acceleration;
|
||||
hasEffectiveRate: boolean = false;
|
||||
filters: Filter[] = [];
|
||||
activeFilters: { [key: string]: boolean } = {};
|
||||
|
||||
tooltipPosition: Position = { x: 0, y: 0 };
|
||||
|
||||
@ViewChild('tooltip') tooltipElement: ElementRef<HTMLCanvasElement>;
|
||||
|
||||
constructor() {}
|
||||
constructor(
|
||||
private cd: ChangeDetectorRef,
|
||||
) {}
|
||||
|
||||
ngOnChanges(changes): void {
|
||||
if (changes.cursorPosition && changes.cursorPosition.currentValue) {
|
||||
@@ -48,17 +54,25 @@ export class BlockOverviewTooltipComponent implements OnChanges {
|
||||
this.tooltipPosition = { x, y };
|
||||
}
|
||||
|
||||
if (changes.tx) {
|
||||
const tx = changes.tx.currentValue || {};
|
||||
this.txid = tx.txid || '';
|
||||
this.fee = tx.fee || 0;
|
||||
this.value = tx.value || 0;
|
||||
this.vsize = tx.vsize || 1;
|
||||
if (this.tx && (changes.tx || changes.filterFlags || changes.filterMode)) {
|
||||
this.txid = this.tx.txid || '';
|
||||
this.fee = this.tx.fee || 0;
|
||||
this.value = this.tx.value || 0;
|
||||
this.vsize = this.tx.vsize || 1;
|
||||
this.feeRate = this.fee / this.vsize;
|
||||
this.effectiveRate = tx.rate;
|
||||
this.acceleration = tx.acc;
|
||||
this.effectiveRate = this.tx.rate;
|
||||
this.acceleration = this.tx.acc;
|
||||
const txFlags = BigInt(this.tx.flags) || 0n;
|
||||
this.hasEffectiveRate = Math.abs((this.fee / this.vsize) - this.effectiveRate) > 0.05
|
||||
|| (tx.bigintFlags && (tx.bigintFlags & (TransactionFlags.cpfp_child | TransactionFlags.cpfp_parent)) > 0n);
|
||||
|| (txFlags && (txFlags & (TransactionFlags.cpfp_child | TransactionFlags.cpfp_parent)) > 0n);
|
||||
this.filters = this.tx.flags ? toFilters(txFlags).filter(f => f.tooltip) : [];
|
||||
this.activeFilters = {}
|
||||
for (const filter of this.filters) {
|
||||
if (this.filterFlags && (this.filterFlags & BigInt(filter.flag))) {
|
||||
this.activeFilters[filter.key] = true;
|
||||
}
|
||||
}
|
||||
this.cd.markForCheck();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user