Commit 101feb4e authored by lianahus's avatar lianahus Committed by Liana Husikyan

JS error catched for getAccounts

parent dc768937
...@@ -390,14 +390,15 @@ class SettingsUI { ...@@ -390,14 +390,15 @@ class SettingsUI {
} }
// TODO: unclear what's the goal of accountListCallId, feels like it can be simplified // TODO: unclear what's the goal of accountListCallId, feels like it can be simplified
fillAccountsList () { async fillAccountsList () {
this.accountListCallId++ this.accountListCallId++
var callid = this.accountListCallId const callid = this.accountListCallId
var txOrigin = this.el.querySelector('#txorigin') const txOrigin = this.el.querySelector('#txorigin')
this.blockchain.getAccounts((err, accounts) => { try {
let accounts = await this.blockchain.getAccounts()
if (this.accountListCallId > callid) return if (this.accountListCallId > callid) return
this.accountListCallId++ this.accountListCallId++
if (err) { addTooltip(`Cannot get account list: ${err}`) } if (!accounts) accounts = []
for (var loadedaddress in this.loadedAccounts) { for (var loadedaddress in this.loadedAccounts) {
if (accounts.indexOf(loadedaddress) === -1) { if (accounts.indexOf(loadedaddress) === -1) {
txOrigin.removeChild(txOrigin.querySelector('option[value="' + loadedaddress + '"]')) txOrigin.removeChild(txOrigin.querySelector('option[value="' + loadedaddress + '"]'))
...@@ -405,14 +406,16 @@ class SettingsUI { ...@@ -405,14 +406,16 @@ class SettingsUI {
} }
} }
for (var i in accounts) { for (var i in accounts) {
var address = accounts[i] const address = accounts[i]
if (!this.loadedAccounts[address]) { if (!this.loadedAccounts[address]) {
txOrigin.appendChild(yo`<option value="${address}" >${address}</option>`) txOrigin.appendChild(yo`<option value="${address}" >${address}</option>`)
this.loadedAccounts[address] = 1 this.loadedAccounts[address] = 1
} }
} }
txOrigin.setAttribute('value', accounts[0]) txOrigin.setAttribute('value', accounts[0])
}) } catch (e) {
addTooltip(`Cannot get account list: ${e}`)
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment