Skip to content
Permalink
Browse files

perf(wallets-controller): use wallet_balances over accounts_balances

  • Loading branch information...
devinus committed Feb 20, 2019
1 parent ad05121 commit 3444535aebc6ea546a889c5a0e69cee93d94da5b
Showing with 10 additions and 16 deletions.
  1. +10 −16 app/wallets/controller.js
@@ -1,7 +1,5 @@
import Controller from '@ember/controller';
import { get } from '@ember/object';
import { A } from '@ember/array';
import { isEmpty } from '@ember/utils';

import { ContextBoundTasksMixin } from 'ember-lifeline';
import { inject as service } from '@ember-decorators/service';
@@ -38,20 +36,16 @@ export default class WalletsController extends Controller.extend(
});
}

async updateBalances(wallet) {
async updateBalances(model) {
const rpc = this.get('rpc');
await rpc.searchPending(get(wallet, 'id'));

const accounts = A(get(wallet, 'accounts')).map(acc => get(acc, 'id'));
if (!isEmpty(accounts)) {
const balances = await rpc.accountsBalances(accounts);
const data = Object.entries(balances).map(([id, attributes]) => ({
id,
attributes,
type: 'account',
}));

this.get('store').push({ data });
}
const wallet = get(model, 'id');
const balances = await rpc.walletBalances(wallet);
const data = Object.entries(balances).map(([id, attributes]) => ({
id,
attributes,
type: 'account',
}));

this.get('store').push({ data });
}
}

0 comments on commit 3444535

Please sign in to comment.
You can’t perform that action at this time.