Refactor services to handle data from meta service.

This commit is contained in:
Spencer Ofwiti 2021-05-18 22:10:08 +03:00
parent 7a2321f444
commit 872bf65786
4 changed files with 7 additions and 6 deletions

View File

@ -46,7 +46,7 @@ export class TransactionService {
}
getAddressTransactions(address: string, offset: number, limit: number): Observable<any> {
return this.httpClient.get(`${environment.cicCacheUrl}/tx/${address}/${offset}/${limit}`);
return this.httpClient.get(`${environment.cicCacheUrl}/tx/user/${address}/${offset}/${limit}`);
}
async setTransaction(transaction, cacheSize: number): Promise<void> {
@ -61,7 +61,7 @@ export class TransactionService {
.pipe(first())
.subscribe(
(res) => {
transaction.sender = this.getAccountInfo(res.body);
transaction.sender = this.getAccountInfo(res);
},
(error) => {
transaction.sender = defaultAccount;
@ -72,7 +72,7 @@ export class TransactionService {
.pipe(first())
.subscribe(
(res) => {
transaction.recipient = this.getAccountInfo(res.body);
transaction.recipient = this.getAccountInfo(res);
},
(error) => {
transaction.recipient = defaultAccount;
@ -96,7 +96,7 @@ export class TransactionService {
.pipe(first())
.subscribe(
(res) => {
conversion.sender = conversion.recipient = this.getAccountInfo(res.body);
conversion.sender = conversion.recipient = this.getAccountInfo(res);
},
(error) => {
conversion.sender = conversion.recipient = defaultAccount;
@ -126,7 +126,7 @@ export class TransactionService {
}
getAccountInfo(account: string): any {
const accountInfo = Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data;
const accountInfo = JSON.parse(Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data);
accountInfo.vcard = vCard.parse(atob(accountInfo.vcard));
return accountInfo;
}

View File

@ -103,6 +103,7 @@ 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]));

View File

@ -42,7 +42,7 @@ Driver.prototype.sync = function (n) {
const processor = async (b, t) => {
return await self.process(b, t);
};
self.syncer(self, self.lo, self.hi, self.filters[0], self.filters[1], countGetter, processor);
self.syncer(self.lo, self.hi, self.filters[0], self.filters[1], countGetter, processor);
};
Driver.prototype.process = function (b, t) {