Remove forceful parsing to JSON format.

This commit is contained in:
Spencer Ofwiti 2021-06-04 15:16:57 +03:00
parent 3831694d3e
commit 9363532284
3 changed files with 13 additions and 14 deletions

View File

@ -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;

View File

@ -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<ArgPair> = [];
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<void> {
this.resetAccountsList();
this.registry.onload = async (addressReturned: string): Promise<void> => {
const accountIndexAddress: string = await this.registry.getContractAddressByName(
'AccountRegistry'
);
const accountIndexQuery = new AccountIndex(accountIndexAddress);
const accountAddresses: Array<string> = 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<string> = 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<void> => {
accountInfo.balance = await this.tokenService.getTokenBalance(

View File

@ -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) => {