diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d820546..96c0507 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -60,6 +60,13 @@ export class AppComponent implements OnInit { 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 { @@ -72,11 +79,6 @@ export class AppComponent implements OnInit { }); // 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) { this.swUpdate.available.subscribe(() => { if (confirm('New Version available. Load New Version?')) { diff --git a/src/app/pages/tokens/tokens.component.ts b/src/app/pages/tokens/tokens.component.ts index cc717d5..9540eb1 100644 --- a/src/app/pages/tokens/tokens.component.ts +++ b/src/app/pages/tokens/tokens.component.ts @@ -29,6 +29,11 @@ export class TokensComponent implements OnInit, AfterViewInit { constructor(private tokenService: TokenService) {} ngOnInit(): void { + this.tokenService.load.subscribe(async (status: boolean) => { + if (status) { + await this.tokenService.getTokens(); + } + }); this.tokenService.tokensSubject.subscribe((tokens) => { this.dataSource = new MatTableDataSource(tokens); this.dataSource.paginator = this.paginator; @@ -38,8 +43,10 @@ export class TokensComponent implements OnInit, AfterViewInit { } ngAfterViewInit(): void { - this.dataSource.paginator = this.paginator; - this.dataSource.sort = this.sort; + if (this.dataSource) { + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } } doFilter(value: string): void {