Subscribe to accounts info in Signer / ParityBar (#4738) (#4856)

This commit is contained in:
Nicolas Gotchac 2017-03-10 15:46:13 +01:00 committed by Jaco Greeff
parent bc9464fcbd
commit dd529575f6

View File

@ -74,28 +74,27 @@ export default class AccountStore {
this._api.parity.getNewDappsAddresses(),
this._api.parity.allAccountsInfo()
])
.then(([whitelist, accounts]) => {
.then(([whitelist, allAccounts]) => {
transaction(() => {
const accounts = Object
.keys(allAccounts)
.filter((address) => {
const account = allAccounts[address];
const isAccount = account.uuid || (account.meta && account.meta.hardware);
const isWhitelisted = !whitelist || whitelist.includes(address);
return isAccount && isWhitelisted;
})
.map((address) => {
return {
...allAccounts[address],
checked: address === this.defaultAccount,
address
};
});
this.setLoading(false);
this.setAccounts(
Object
.keys(accounts)
.filter((address) => {
const account = accounts[address];
const isAccount = account.uuid || (account.meta && account.meta.hardware);
const isWhitelisted = !whitelist || whitelist.includes(address);
return isAccount && isWhitelisted;
})
.map((address) => {
const account = accounts[address];
account.address = address;
account.checked = address === this.defaultAccount;
return account;
})
);
this.setAccounts(accounts);
});
})
.catch((error) => {
@ -117,6 +116,13 @@ export default class AccountStore {
}
});
return Promise.all([ promiseDefaultAccount, promiseEthAccounts ]);
const promiseAccountsInfo = this._api
.subscribe('parity_allAccountsInfo', (error, accountsInfo) => {
if (!error) {
this.loadAccounts();
}
});
return Promise.all([ promiseDefaultAccount, promiseEthAccounts, promiseAccountsInfo ]);
}
}