Skip to content

Commit

Permalink
Fix stats on home page (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanSerikov committed Jan 18, 2021
1 parent 014022f commit 2dec8db
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/views/home/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
color="border"
class="text--secondary mr-5"
to="/dapps"
><v-icon left color="error">mdi-fire</v-icon>Explore DApps</v-btn
><v-icon left color="error">mdi-fire</v-icon>Explore
DApps</v-btn
>
<v-btn
large
Expand Down Expand Up @@ -141,6 +142,7 @@ export default {
connecting: true,
pickingRandom: false,
hasOpenCallback: false,
synced: false,
}),
mounted() {
if (this.$route.name != this.config.HOME_PAGE) {
Expand Down Expand Up @@ -179,28 +181,29 @@ export default {
});
},
onMessage(data) {
if (data.body) {
if (this.stats.length == 0) {
this.stats = data.body.sort(function (a, b) {
if (a.network === "mainnet") {
return -1;
} else if (b.network === "mainnet") {
return 1;
} else {
return b.network.localeCompare(a.network);
}
});
for (let i = 0; i < this.stats.length; i++) {
this.indices[this.stats[i].network] = i
if (data.body === undefined) {
return;
}
if (!this.synced && this.config.networks.length == data.body.length) {
this.stats = data.body.sort(function (a, b) {
if (a.network === "mainnet") {
return -1;
} else if (b.network === "mainnet") {
return 1;
} else {
return b.network.localeCompare(a.network);
}
} else {
for (let i = 0; i < data.body.length; i++){
let idx = this.indices[data.body[i].network];
if (idx !== undefined) {
Object.assign(this.stats[idx], data.body[i]);
} else {
this.stats.push(data.body[i])
}
});
for (let i = 0; i < this.stats.length; i++) {
this.indices[this.stats[i].network] = i;
}
this.synced = true;
} else if (this.synced) {
for (let i = 0; i < data.body.length; i++) {
let idx = this.indices[data.body[i].network];
if (idx !== undefined) {
Object.assign(this.stats[idx], data.body[i]);
}
}
}
Expand Down

0 comments on commit 2dec8db

Please sign in to comment.