Check for token route before loading tokens in app component.

This commit is contained in:
Spencer Ofwiti 2021-07-04 12:20:44 +03:00
parent 0ba5b74856
commit 617741e7a9
2 changed files with 16 additions and 7 deletions

View File

@ -60,6 +60,13 @@ export class AppComponent implements OnInit {
this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error }); this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error });
} }
} }
if (!this.url.includes('tokens')) {
this.tokenService.load.subscribe(async (status: boolean) => {
if (status) {
await this.tokenService.getTokens();
}
});
}
} }
}); });
try { try {
@ -72,11 +79,6 @@ export class AppComponent implements OnInit {
}); });
// TODO do something to halt user progress...show a sad cicada page 🦗? // TODO do something to halt user progress...show a sad cicada page 🦗?
} }
this.tokenService.load.subscribe(async (status: boolean) => {
if (status) {
await this.tokenService.getTokens();
}
});
if (!this.swUpdate.isEnabled) { if (!this.swUpdate.isEnabled) {
this.swUpdate.available.subscribe(() => { this.swUpdate.available.subscribe(() => {
if (confirm('New Version available. Load New Version?')) { if (confirm('New Version available. Load New Version?')) {

View File

@ -29,6 +29,11 @@ export class TokensComponent implements OnInit, AfterViewInit {
constructor(private tokenService: TokenService) {} constructor(private tokenService: TokenService) {}
ngOnInit(): void { ngOnInit(): void {
this.tokenService.load.subscribe(async (status: boolean) => {
if (status) {
await this.tokenService.getTokens();
}
});
this.tokenService.tokensSubject.subscribe((tokens) => { this.tokenService.tokensSubject.subscribe((tokens) => {
this.dataSource = new MatTableDataSource(tokens); this.dataSource = new MatTableDataSource(tokens);
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
@ -38,8 +43,10 @@ export class TokensComponent implements OnInit, AfterViewInit {
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
this.dataSource.paginator = this.paginator; if (this.dataSource) {
this.dataSource.sort = this.sort; this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
} }
doFilter(value: string): void { doFilter(value: string): void {