2020-12-20 23:36:04 +00:00
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
2022-05-17 02:53:13 +00:00
|
|
|
import { Router, ResolveEnd, Event } from '@angular/router';
|
2020-12-20 23:36:04 +00:00
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
import { takeUntil, filter } from 'rxjs/operators';
|
2020-03-10 17:25:52 +00:00
|
|
|
import { faUserCheck } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
|
|
|
|
@Component({
|
2022-05-01 17:35:20 +00:00
|
|
|
selector: 'rtl-cln-sign-verify-message',
|
2020-03-10 17:25:52 +00:00
|
|
|
templateUrl: './sign-verify-message.component.html',
|
|
|
|
styleUrls: ['./sign-verify-message.component.scss']
|
|
|
|
})
|
2022-05-01 17:35:20 +00:00
|
|
|
export class CLNSignVerifyMessageComponent implements OnInit, OnDestroy {
|
2021-08-28 21:03:18 +00:00
|
|
|
|
2020-03-10 17:25:52 +00:00
|
|
|
public faUserCheck = faUserCheck;
|
2021-08-28 21:03:18 +00:00
|
|
|
public links = [{ link: 'sign', name: 'Sign' }, { link: 'verify', name: 'Verify' }];
|
2020-12-20 23:36:04 +00:00
|
|
|
public activeLink = this.links[0].link;
|
|
|
|
private unSubs: Array<Subject<void>> = [new Subject(), new Subject()];
|
2020-03-10 17:25:52 +00:00
|
|
|
|
2022-05-01 17:35:20 +00:00
|
|
|
constructor(private router: Router) { }
|
2020-12-20 23:36:04 +00:00
|
|
|
|
|
|
|
ngOnInit() {
|
2021-08-28 21:03:18 +00:00
|
|
|
const linkFound = this.links.find((link) => this.router.url.includes(link.link));
|
2020-12-20 23:36:04 +00:00
|
|
|
this.activeLink = linkFound ? linkFound.link : this.links[0].link;
|
2021-08-28 21:03:18 +00:00
|
|
|
this.router.events.pipe(takeUntil(this.unSubs[0]), filter((e) => e instanceof ResolveEnd)).
|
2022-05-17 02:53:13 +00:00
|
|
|
subscribe({
|
|
|
|
next: (value: ResolveEnd | Event) => {
|
|
|
|
const linkFound = this.links.find((link) => (<ResolveEnd>value).urlAfterRedirects.includes(link.link));
|
|
|
|
this.activeLink = linkFound ? linkFound.link : this.links[0].link;
|
|
|
|
}
|
2021-08-28 21:03:18 +00:00
|
|
|
});
|
2020-12-20 23:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
2021-08-28 21:03:18 +00:00
|
|
|
this.unSubs.forEach((completeSub) => {
|
2021-06-20 20:27:08 +00:00
|
|
|
completeSub.next(null);
|
2020-12-20 23:36:04 +00:00
|
|
|
completeSub.complete();
|
|
|
|
});
|
|
|
|
}
|
2020-03-10 17:25:52 +00:00
|
|
|
|
|
|
|
}
|