You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
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<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
|
|
|
|
constructor(private store: Store<fromRTLReducer.State>) { }
|
|
|
|
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;
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|