add autoclean storage
This commit is contained in:
parent
f03ee64cfa
commit
f11c119f43
@ -185,8 +185,19 @@ export default class ChainFetch {
|
|||||||
async getValidatorList(config = null) {
|
async getValidatorList(config = null) {
|
||||||
return this.get('/cosmos/staking/v1beta1/validators?pagination.limit=200&status=BOND_STATUS_BONDED', config).then(data => {
|
return this.get('/cosmos/staking/v1beta1/validators?pagination.limit=200&status=BOND_STATUS_BONDED', config).then(data => {
|
||||||
const vals = commonProcess(data.validators).map(i => new Validator().init(i))
|
const vals = commonProcess(data.validators).map(i => new Validator().init(i))
|
||||||
// disable cache
|
try {
|
||||||
// localStorage.setItem(`validators-${this.config.chain_name}`, JSON.stringify(vals))
|
localStorage.setItem(`validators-${this.config.chain_name}`, JSON.stringify(vals))
|
||||||
|
} catch (err) {
|
||||||
|
// clear cache
|
||||||
|
for (let i = 0; i < localStorage.length; i += 1) {
|
||||||
|
const key = localStorage.key(i)
|
||||||
|
if (key.startsWith('validators')) {
|
||||||
|
localStorage.removeItem(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// set again
|
||||||
|
localStorage.setItem(`validators-${this.config.chain_name}`, JSON.stringify(vals))
|
||||||
|
}
|
||||||
return vals
|
return vals
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -279,10 +279,10 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// const cached = JSON.parse(getCachedValidators(this.$route.params.chain))
|
const cached = JSON.parse(getCachedValidators(this.$route.params.chain))
|
||||||
// if (cached) {
|
if (cached) {
|
||||||
// this.validators = cached
|
this.validators = cached
|
||||||
// }
|
}
|
||||||
this.$http.getValidatorList().then(res => {
|
this.$http.getValidatorList().then(res => {
|
||||||
this.validators = res
|
this.validators = res
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user