Skip to content

Commit bc1038c

Browse files
committed
Fix bug with cannot set property "account" of undefined. Related to the too often refreshing the list of nodes. Add the block of refresh button until the list is ready
1 parent 976ec00 commit bc1038c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/pages/Index.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178

179179
<template v-slot:action>
180180
<q-btn size="md" outline color="vgreen" label="Rules" class="q-mx-xs" v-on:click="rulesDialog=true" />
181-
<q-btn size="md" outline color="vgreen" icon="fas fa-sync-alt" class="q-mx-xs" v-on:click=refresh />
181+
<q-btn size="md" outline color="vgreen" icon="fas fa-sync-alt" class="q-mx-xs" :disabled="nodes.length && nodes.every(item => item.balance && item.account) ? false : true" v-on:click=refresh />
182182
</template>
183183
</q-banner>
184184
<q-scroll-area style="height: 300pt;">
@@ -783,14 +783,19 @@ export default {
783783
const eos = new this.$EosWrapper()
784784
this.running_nodes = this.nodes.length
785785
this.getRegisteredNodes()
786-
for (var id in this.nodes) {
787-
// this.getAccountByKey(id, this.nodes[id].key)
788-
this.getAccountName(id, this.nodes[id].key, eos)
786+
if (this.nodes.length > 0) {
787+
for (var id in this.nodes) {
788+
// this.getAccountByKey(id, this.nodes[id].key)
789+
this.getAccountName(id, this.nodes[id].key, eos)
790+
}
791+
} else {
792+
this.$userError('Oops, too often refresh, please try later.', 'Get list of Nodes action')
789793
}
790794
},
791795
async getNodes () {
792796
return new Promise(resolve => {
793797
this.$http.get(process.env.NODES_API + '/getConnectedNodes').then((result) => {
798+
// TODO: Handler if the object is empty of has result: null or result: try later
794799
for (var key in result.data) {
795800
if (result.data[key].includes('EOS')) {
796801
this.nodes.push({ id: key, key: result.data[key].trim(), account: '', vote: true })

0 commit comments

Comments
 (0)