chore: skip picking if VEGA_URL set
This commit is contained in:
parent
635445f23b
commit
b0bbae4c2e
@ -619,6 +619,12 @@ export const useEnvironment = create<EnvStore>()((set, get) => ({
|
|||||||
|
|
||||||
const state = get();
|
const state = get();
|
||||||
|
|
||||||
|
// skip picking up the best node if VEGA_URL env variable is set
|
||||||
|
if (state.VEGA_URL && isValidUrl(state.VEGA_URL)) {
|
||||||
|
state.setUrl(state.VEGA_URL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let storedUrl = LocalStorage.getItem(STORAGE_KEY);
|
let storedUrl = LocalStorage.getItem(STORAGE_KEY);
|
||||||
if (!isValidUrl(storedUrl)) {
|
if (!isValidUrl(storedUrl)) {
|
||||||
// remove invalid data from local storage
|
// remove invalid data from local storage
|
||||||
@ -667,24 +673,21 @@ export const useEnvironment = create<EnvStore>()((set, get) => ({
|
|||||||
// remove unhealthy node url from local storage
|
// remove unhealthy node url from local storage
|
||||||
LocalStorage.removeItem(STORAGE_KEY);
|
LocalStorage.removeItem(STORAGE_KEY);
|
||||||
}
|
}
|
||||||
// A node's url (VEGA_URL) is either the requsted node (previously
|
// A node's url (VEGA_URL) is either the requested node (previously
|
||||||
// connected or taken form env variable) or the currently best available
|
// connected or taken form env variable) or the currently best available
|
||||||
// node.
|
// node.
|
||||||
const url = requestedNode?.url || bestNode?.url;
|
const url = requestedNode?.url || bestNode?.url;
|
||||||
|
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
set({
|
state.setUrl(url);
|
||||||
status: 'success',
|
return;
|
||||||
VEGA_URL: url,
|
|
||||||
});
|
|
||||||
LocalStorage.setItem(STORAGE_KEY, url);
|
|
||||||
} else {
|
|
||||||
set({
|
|
||||||
status: 'failed',
|
|
||||||
error: 'No suitable node found',
|
|
||||||
});
|
|
||||||
console.warn('No suitable node was found');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set({
|
||||||
|
status: 'failed',
|
||||||
|
error: 'No suitable node found',
|
||||||
|
});
|
||||||
|
console.warn('No suitable node was found');
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user