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> { 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> { async setTransaction(transaction, cacheSize: number): Promise<void> {
@ -61,7 +61,7 @@ export class TransactionService {
.pipe(first()) .pipe(first())
.subscribe( .subscribe(
(res) => { (res) => {
transaction.sender = this.getAccountInfo(res.body); transaction.sender = this.getAccountInfo(res);
}, },
(error) => { (error) => {
transaction.sender = defaultAccount; transaction.sender = defaultAccount;
@ -72,7 +72,7 @@ export class TransactionService {
.pipe(first()) .pipe(first())
.subscribe( .subscribe(
(res) => { (res) => {
transaction.recipient = this.getAccountInfo(res.body); transaction.recipient = this.getAccountInfo(res);
}, },
(error) => { (error) => {
transaction.recipient = defaultAccount; transaction.recipient = defaultAccount;
@ -96,7 +96,7 @@ export class TransactionService {
.pipe(first()) .pipe(first())
.subscribe( .subscribe(
(res) => { (res) => {
conversion.sender = conversion.recipient = this.getAccountInfo(res.body); conversion.sender = conversion.recipient = this.getAccountInfo(res);
}, },
(error) => { (error) => {
conversion.sender = conversion.recipient = defaultAccount; conversion.sender = conversion.recipient = defaultAccount;
@ -126,7 +126,7 @@ export class TransactionService {
} }
getAccountInfo(account: string): any { 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)); accountInfo.vcard = vCard.parse(atob(accountInfo.vcard));
return accountInfo; return accountInfo;
} }

View File

@ -103,6 +103,7 @@ export class UserService {
.subscribe( .subscribe(
async (res) => { async (res) => {
const syncableAccount: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap(); const syncableAccount: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap();
syncableAccount.m.data = JSON.parse(syncableAccount.m.data);
const update: Array<ArgPair> = []; const update: Array<ArgPair> = [];
for (const prop of Object.keys(accountInfo)) { for (const prop of Object.keys(accountInfo)) {
update.push(new ArgPair(prop, accountInfo[prop])); update.push(new ArgPair(prop, accountInfo[prop]));

View File

@ -42,7 +42,7 @@ Driver.prototype.sync = function (n) {
const processor = async (b, t) => { const processor = async (b, t) => {
return await self.process(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) { Driver.prototype.process = function (b, t) {