import { Component, OnInit, Input } from '@angular/core'; import { formatDate } from '@angular/common'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { ChannelEdge } from '../../../shared/models/lndModels'; import * as fromRTLReducer from '../../../shared/store/rtl.reducers'; @Component({ selector: 'rtl-channel-lookup', templateUrl: './channel-lookup.component.html', styleUrls: ['./channel-lookup.component.css'] }) export class ChannelLookupComponent implements OnInit { @Input() lookupResult: ChannelEdge; public node1_match = false; public node2_match = false; private unSubs: Array> = [new Subject(), new Subject(), new Subject(), new Subject()]; constructor(private store: Store) { } ngOnInit() { if (undefined !== this.lookupResult && undefined !== this.lookupResult.last_update_str) { this.lookupResult.last_update_str = (this.lookupResult.last_update_str === '') ? '' : formatDate(this.lookupResult.last_update_str, 'MMM/dd/yy HH:mm:ss', 'en-US'); } this.store.select('rtlRoot') .pipe(takeUntil(this.unSubs[0])) .subscribe((rtlStore: fromRTLReducer.State) => { if (this.lookupResult.node1_pub === rtlStore.information.identity_pubkey) { this.node1_match = true; } if (this.lookupResult.node2_pub === rtlStore.information.identity_pubkey) { this.node2_match = true; } }); } }