diff --git a/src/layouts/components/ChainProfile.vue b/src/layouts/components/ChainProfile.vue index b9d4628d..1b0589d2 100644 --- a/src/layouts/components/ChainProfile.vue +++ b/src/layouts/components/ChainProfile.vue @@ -5,7 +5,7 @@ const baseStore = useBaseStore(); chainStore.initial(); chainStore.$subscribe((m, s) => { if (!Array.isArray(m.events) && m.events.key === 'endpoint') { - chainStore.initial(); + // chainStore.initial(); } }); diff --git a/src/router/index.ts b/src/router/index.ts index 20ca2ac5..682f75e4 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -13,7 +13,9 @@ router.beforeEach((to) => { const { chain } = to.params if(chain){ const blockchain = useBlockchain() - blockchain.setCurrent(chain.toString()) + if(chain !== blockchain.chainName) { + blockchain.setCurrent(chain.toString()) + } } }) diff --git a/src/stores/useBlockchain.ts b/src/stores/useBlockchain.ts index 9e11c3c8..502c8f94 100644 --- a/src/stores/useBlockchain.ts +++ b/src/stores/useBlockchain.ts @@ -122,11 +122,16 @@ export const useBlockchain = defineStore('blockchain', { }, async randomSetupEndpoint() { - const all = this.current?.endpoints?.rest; - if (all) { - const rn = Math.random(); - const endpoint = all[Math.floor(rn * all.length)]; - await this.setRestEndpoint(endpoint); + const end = localStorage.getItem(`endpoint-${this.chainName}`) + if(end) { + this.setRestEndpoint(JSON.parse(end)) + } else { + const all = this.current?.endpoints?.rest; + if (all) { + const rn = Math.random(); + const endpoint = all[Math.floor(rn * all.length)]; + await this.setRestEndpoint(endpoint); + } } }, @@ -134,9 +139,12 @@ export const useBlockchain = defineStore('blockchain', { this.connErr = ''; this.endpoint = endpoint; this.rpc = new CosmosRestClient(endpoint.address, DEFAULT); + localStorage.setItem(`endpoint-${this.chainName}`, JSON.stringify(endpoint)) }, setCurrent(name: string) { - this.chainName = name; + if(name !== this.chainName) { + this.chainName = name; + } }, }, });