This commit is contained in:
liangping
2023-04-07 10:11:48 +08:00
parent 8c31935432
commit d3a7c6f176
14 changed files with 142 additions and 68 deletions
+4 -1
View File
@@ -151,7 +151,10 @@ export const useFormatter = defineStore('formatter', {
})
return output.join(', ')
}
},
},
multiLine(v: string) {
return v? v.replaceAll("\\n","\n"): ""
}
}
})
+21 -4
View File
@@ -1,6 +1,7 @@
import { defineStore } from "pinia";
import { useBlockchain } from "./useBlockchain";
import type { PageRequest } from "@/types";
import type { PageRequest, PaginatedProposals } from "@/types";
import { LoadingStatus } from "./useDashboard";
export const useGovStore = defineStore('govStore', {
state: () => {
@@ -9,7 +10,9 @@ export const useGovStore = defineStore('govStore', {
deposit: {},
voting: {},
tally: {},
}
},
proposals: {} as Record<string, PaginatedProposals>,
loading: {} as Record<string, LoadingStatus>
}
},
getters: {
@@ -22,8 +25,22 @@ export const useGovStore = defineStore('govStore', {
this.fetchParams()
},
async fetchProposals( status: string, pagination?: PageRequest ) {
const proposals = await this.blockchain.rpc.getGovProposals(status)
return proposals
if(!this.loading[status]) {
this.loading[status] = LoadingStatus.Loading
const proposals = await this.blockchain.rpc.getGovProposals(status)
this.loading[status] = LoadingStatus.Loaded
this.proposals[status] = proposals
if(status === '2') {
proposals.proposals.forEach(x1 => {
this.fetchTally(x1.proposal_id).then(t => {
x1.final_tally_result = t.tally
this.proposals[status] = proposals
})
})
}
}
return this.proposals[status]
},
async fetchParams() {
// this.blockchain.rpc.getGovParamsDeposit().then(x => {