From 6a2c9004d87b3aa8f8ef629352a5275ebee88a74 Mon Sep 17 00:00:00 2001 From: Dexter Edwards Date: Tue, 9 May 2023 20:57:11 +0100 Subject: [PATCH] fix(governance, console, explorer): show vega node in list, cache bust (#3676) --- libs/environment/src/hooks/use-environment.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/environment/src/hooks/use-environment.ts b/libs/environment/src/hooks/use-environment.ts index 14f16e441..69cce83a8 100644 --- a/libs/environment/src/hooks/use-environment.ts +++ b/libs/environment/src/hooks/use-environment.ts @@ -15,6 +15,7 @@ import { Networks } from '../types'; import { compileErrors } from '../utils/compile-errors'; import { envSchema } from '../utils/validate-environment'; import { tomlConfigSchema } from '../utils/validate-configuration'; +import uniq from 'lodash/uniq'; type Client = ReturnType; type ClientCollection = { @@ -32,7 +33,8 @@ type Actions = { export type Env = Environment & EnvState; export type EnvStore = Env & Actions; -export const STORAGE_KEY = 'vega_url'; +const VERSION = 1; +export const STORAGE_KEY = `vega_url_${VERSION}`; const SUBSCRIPTION_TIMEOUT = 3000; export const useEnvironment = create()((set, get) => ({ @@ -69,7 +71,10 @@ export const useEnvironment = create()((set, get) => ({ let nodes: string[] | undefined; try { nodes = await fetchConfig(state.VEGA_CONFIG_URL); - set({ nodes }); + const enrichedNodes = uniq( + [...nodes, state.VEGA_URL, storedUrl].filter(Boolean) as string[] + ); + set({ nodes: enrichedNodes }); } catch (err) { console.warn(`Could not fetch node config from ${state.VEGA_CONFIG_URL}`); }