add queue for votes loading

This commit is contained in:
liangping 2022-04-24 21:30:12 +08:00
parent e62e642d65
commit 3ffd28bc08

View File

@ -180,7 +180,7 @@ export default {
islive: true, islive: true,
proposals: [], proposals: [],
tally: {}, tally: {},
voters: [], // need to be query. // voters: [], // need to be query.
votes: [], // votes of voters votes: [], // votes of voters
} }
}, },
@ -256,13 +256,23 @@ export default {
}, },
fetchProposals(item) { fetchProposals(item) {
if (this.islive) { if (this.islive) {
let promise = Promise.resolve()
// identities.forEach(item => {
// promise = promise.then(() => new Promise(resolve => {
// this.avatar(item, resolve)
// }))
// })
this.$http.getGovernanceListByStatus(2, item.conf).then(data => { this.$http.getGovernanceListByStatus(2, item.conf).then(data => {
data.proposals.forEach(p => { data.proposals.forEach(p => {
const p2 = p const p2 = p
p2.chain = item.conf p2.chain = item.conf
this.proposals.push(p2) this.proposals.push(p2)
item.addresses.forEach(a => { item.addresses.forEach(a => {
this.fetchMyVote(p.id, a, item.conf) // this.fetchMyVote(p.id, a, item.conf)
// this.voters.push({ pid: p.id, addr: a, conf: item.conf })
promise = promise.then(() => new Promise(resolve => {
this.fetchMyVote(p.id, a, item.conf, resolve)
}))
}) })
}) })
this.updateTally(data.proposals, item.conf) this.updateTally(data.proposals, item.conf)
@ -271,13 +281,16 @@ export default {
}) })
} }
}, },
fetchMyVote(pid, addr, chain) { fetchMyVote(pid, addr, conf, resolve) {
if (this.islive) { if (this.islive) {
this.$http.getGovernanceProposalVote(pid, addr, chain).then(data => { this.$http.getGovernanceProposalVote(pid, addr, conf).then(data => {
resolve()
const x = data const x = data
x.keyname = this.keyname(data.vote.voter) x.keyname = this.keyname(data.vote.voter)
this.votes.push(x) this.votes.push(x)
}).catch(() => { }) }).catch(() => {
resolve()
})
} }
}, },
updateTally(voting, chain) { updateTally(voting, chain) {