Add account object interface.

Add new vcard parser.
This commit is contained in:
Spencer Ofwiti
2021-03-02 10:29:14 +03:00
parent 2491dc54a0
commit 0d7f4aae13
9 changed files with 81 additions and 48 deletions

View File

@@ -5,7 +5,7 @@ import {environment} from '@src/environments/environment';
import {first} from 'rxjs/operators';
import {AccountIndex, MutableKeyStore, MutablePgpKeyStore, PGPSigner, Signer} from '@app/_helpers';
import {ArgPair, Envelope, Syncable, User} from 'cic-client-meta';
import {parse} from '@src/assets/js/parse-vcard';
const vCard = require('vcard-parser');
@Injectable({
providedIn: 'root'
@@ -16,6 +16,7 @@ export class UserService {
signer: Signer = new PGPSigner(this.keystore);
accountIndexQuery = new AccountIndex(environment.contractAddress);
accountsMeta = [];
accounts: any = [];
private accountsList = new BehaviorSubject<any>(this.accounts);
accountsSubject = this.accountsList.asObservable();
@@ -155,8 +156,10 @@ export class UserService {
const accountAddresses = await this.accountIndexQuery.last(await this.accountIndexQuery.totalAccounts());
for (const accountAddress of accountAddresses.slice(offset, offset + limit)) {
this.getAccountDetailsFromMeta(await User.toKey(accountAddress)).pipe(first()).subscribe(res => {
const accountInfo = Envelope.fromJSON(JSON.stringify(res)).unwrap().m.data;
accountInfo.vcard = parse(atob(accountInfo.vcard));
const account = Envelope.fromJSON(JSON.stringify(res)).unwrap();
this.accountsMeta.push(account);
const accountInfo = account.m.data;
accountInfo.vcard = vCard.parse(atob(accountInfo.vcard));
this.accounts.push(accountInfo);
this.accountsList.next(this.accounts);
});