Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 2x 17x 5x 5x 5x 5x 5x 2x 2x 2x 1x 7x 7x 7x 7x 7x 5x 5x 5x 5x 5x | import { CommonModule, DatePipe } from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Input,
inject
} from '@angular/core';
import { CompleteInteractionData, Interaction } from '@reflex/shared-types';
@Component({
selector: 'app-interactions',
templateUrl: './interactions.component.html',
styleUrls: ['./interactions.component.scss'],
changeDetection: ChangeDetectionStrategy.Eager,
imports: [CommonModule]
})
export class InteractionsComponent {
public interactions: CompleteInteractionData = {
raw: [],
absolute: [],
normalized: []
};
public calibratedInteractions: Array<Interaction> = [];
private readonly changeDetector = inject(ChangeDetectorRef);
private pIsProcessing = false;
private readonly datePipe: DatePipe = new DatePipe('en-US', '+0000');
public get isProcessing(): boolean {
return this.pIsProcessing;
}
@Input()
public set isProcessing(value: boolean) {
this.pIsProcessing = value;
if (!this.pIsProcessing) {
this.interactions = { raw: [], absolute: [], normalized: [] };
}
}
public getTime(ticks: number): string {
// ticks are in nanotime; convert to microtime
const ticksToMicrotime = Math.floor(ticks / 10000);
// ticks are recorded from 1/1/1; get microtime difference from 1/1/1/ to 1/1/1970
const epochMicrotimeDiff = 62135596800000;
// new date is ticks, converted to microtime, minus difference from epoch microtime
const tickDate = ticksToMicrotime - epochMicrotimeDiff;
const resultDate = new Date(tickDate);
return this.datePipe.transform(
resultDate.getTime(),
'HH:mm:ss.SSS'
) as string;
}
public updateInteractions(interactions: CompleteInteractionData): void {
const maxItems = Math.min(interactions.raw.length, 10);
this.interactions.raw = interactions.raw.slice(0, maxItems);
this.interactions.normalized = interactions.normalized.slice(0, maxItems);
this.interactions.absolute = interactions.absolute.slice(0, maxItems);
this.changeDetector.markForCheck();
}
}
|