diff --git a/src/app/_services/transaction.service.ts b/src/app/_services/transaction.service.ts index 09367ee..5a6c7d8 100644 --- a/src/app/_services/transaction.service.ts +++ b/src/app/_services/transaction.service.ts @@ -136,7 +136,7 @@ export class TransactionService { } getAccountInfo(account: string, cacheSize: number = 100): any { - const accountInfo = JSON.parse(Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data); + const accountInfo = Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data; accountInfo.vcard = vCard.parse(atob(accountInfo.vcard)); this.userService.addAccount(accountInfo, cacheSize); return accountInfo; diff --git a/src/app/_services/user.service.ts b/src/app/_services/user.service.ts index cc9685e..e1db2d5 100644 --- a/src/app/_services/user.service.ts +++ b/src/app/_services/user.service.ts @@ -104,7 +104,6 @@ export class UserService { .subscribe( async (res) => { const syncableAccount: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap(); - syncableAccount.m.data = JSON.parse(syncableAccount.m.data); const update: Array = []; for (const prop of Object.keys(accountInfo)) { update.push(new ArgPair(prop, accountInfo[prop])); @@ -180,17 +179,15 @@ export class UserService { async loadAccounts(limit: number = 100, offset: number = 0): Promise { this.resetAccountsList(); - this.registry.onload = async (addressReturned: string): Promise => { - const accountIndexAddress: string = await this.registry.getContractAddressByName( - 'AccountRegistry' - ); - const accountIndexQuery = new AccountIndex(accountIndexAddress); - const accountAddresses: Array = await accountIndexQuery.last(limit); - this.loggingService.sendInfoLevelMessage(accountAddresses); - for (const accountAddress of accountAddresses.slice(offset, offset + limit)) { - await this.getAccountByAddress(accountAddress, limit); - } - }; + const accountIndexAddress: string = await this.registry.getContractAddressByName( + 'AccountRegistry' + ); + const accountIndexQuery = new AccountIndex(accountIndexAddress); + const accountAddresses: Array = await accountIndexQuery.last(limit); + this.loggingService.sendInfoLevelMessage(accountAddresses); + for (const accountAddress of accountAddresses.slice(offset, offset + limit)) { + await this.getAccountByAddress(accountAddress, limit); + } } async getAccountByAddress( @@ -202,7 +199,7 @@ export class UserService { .pipe(first()) .subscribe(async (res) => { const account: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap(); - const accountInfo = JSON.parse(account.m.data); + const accountInfo = account.m.data; await personValidation(accountInfo); this.tokenService.onload = async (status: boolean): Promise => { accountInfo.balance = await this.tokenService.getTokenBalance( 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 5feca04..312682a 100644 --- a/src/app/pages/accounts/account-details/account-details.component.ts +++ b/src/app/pages/accounts/account-details/account-details.component.ts @@ -104,6 +104,7 @@ export class AccountDetailsComponent implements OnInit { await this.transactionService.init(); await this.userService.init(); await this.blockSyncService.blockSync(this.accountAddress); + this.userService.resetAccountsList(); (await this.userService.getAccountByAddress(this.accountAddress, 100)).subscribe( async (res) => { if (res !== undefined) { @@ -154,6 +155,7 @@ export class AccountDetailsComponent implements OnInit { this.userDataSource.paginator = this.userTablePaginator; this.userDataSource.sort = this.userTableSort; this.accounts = accounts; + this.cdr.detectChanges(); }); this.transactionService.transactionsSubject.subscribe((transactions) => {