From 9439e253705385f85069dc0b3d76004aae686e6f Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Wed, 9 Jun 2021 18:52:59 +0300 Subject: [PATCH] Add type to token service load subject. --- src/app/_services/user.service.ts | 12 +++++++----- .../account-details/account-details.component.ts | 2 +- src/app/pages/tokens/tokens.component.ts | 8 +++++--- .../transaction-details.component.ts | 2 +- src/app/pages/transactions/transactions.component.ts | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/app/_services/user.service.ts b/src/app/_services/user.service.ts index e1db2d5..95d359a 100644 --- a/src/app/_services/user.service.ts +++ b/src/app/_services/user.service.ts @@ -201,11 +201,13 @@ export class UserService { const account: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap(); const accountInfo = account.m.data; await personValidation(accountInfo); - this.tokenService.onload = async (status: boolean): Promise => { - accountInfo.balance = await this.tokenService.getTokenBalance( - accountInfo.identities.evm[`bloxberg:${environment.bloxbergChainId}`][0] - ); - }; + this.tokenService.load.subscribe(async (status: boolean) => { + if (status) { + accountInfo.balance = await this.tokenService.getTokenBalance( + accountInfo.identities.evm[`bloxberg:${environment.bloxbergChainId}`][0] + ); + } + }); accountInfo.vcard = vCard.parse(atob(accountInfo.vcard)); await vcardValidation(accountInfo.vcard); this.addAccount(accountInfo, limit); diff --git a/src/app/pages/accounts/account-details/account-details.component.ts b/src/app/pages/accounts/account-details/account-details.component.ts index e08703d..9c766be 100644 --- a/src/app/pages/accounts/account-details/account-details.component.ts +++ b/src/app/pages/accounts/account-details/account-details.component.ts @@ -190,7 +190,7 @@ export class AccountDetailsComponent implements OnInit { .getGenders() .pipe(first()) .subscribe((res) => (this.genders = res)); - this.tokenService.load.subscribe(async (status) => { + this.tokenService.load.subscribe(async (status: boolean) => { if (status) { this.tokenSymbol = await this.tokenService.getTokenSymbol(); } diff --git a/src/app/pages/tokens/tokens.component.ts b/src/app/pages/tokens/tokens.component.ts index 3c86267..9f96497 100644 --- a/src/app/pages/tokens/tokens.component.ts +++ b/src/app/pages/tokens/tokens.component.ts @@ -29,9 +29,11 @@ export class TokensComponent implements OnInit { async ngOnInit(): Promise { await this.tokenService.init(); - this.tokenService.onload = async (status: boolean): Promise => { - await this.tokenService.getTokens(); - }; + this.tokenService.load.subscribe(async (status: boolean) => { + if (status) { + await this.tokenService.getTokens(); + } + }); this.tokenService.tokensSubject.subscribe((tokens) => { this.loggingService.sendInfoLevelMessage(tokens); this.dataSource = new MatTableDataSource(tokens); diff --git a/src/app/pages/transactions/transaction-details/transaction-details.component.ts b/src/app/pages/transactions/transaction-details/transaction-details.component.ts index a2029ca..29322bb 100644 --- a/src/app/pages/transactions/transaction-details/transaction-details.component.ts +++ b/src/app/pages/transactions/transaction-details/transaction-details.component.ts @@ -48,7 +48,7 @@ export class TransactionDetailsComponent implements OnInit { this.recipientBloxbergLink = 'https://blockexplorer.bloxberg.org/address/' + this.transaction?.to + '/transactions'; } - this.tokenService.load.subscribe(async (status) => { + this.tokenService.load.subscribe(async (status: boolean) => { if (status) { this.tokenSymbol = await this.tokenService.getTokenSymbol(); this.tokenName = await this.tokenService.getTokenName(); diff --git a/src/app/pages/transactions/transactions.component.ts b/src/app/pages/transactions/transactions.component.ts index 49f52d2..6ae36f3 100644 --- a/src/app/pages/transactions/transactions.component.ts +++ b/src/app/pages/transactions/transactions.component.ts @@ -56,7 +56,7 @@ export class TransactionsComponent implements OnInit, AfterViewInit { .getTransactionTypes() .pipe(first()) .subscribe((res) => (this.transactionsTypes = res)); - this.tokenService.load.subscribe(async (status) => { + this.tokenService.load.subscribe(async (status: boolean) => { if (status) { this.tokenSymbol = await this.tokenService.getTokenSymbol(); }