Make silent preload of orchestrator info not modify local browser cache and also look at delegator cache before preloading

This commit is contained in:
Marco van Dijk 2022-04-22 00:13:58 +02:00
parent 9cd691afae
commit e69338ed5f
2 changed files with 16 additions and 10 deletions

View File

@ -146,14 +146,8 @@ export const getCurrentOrchestratorInfo = () => async dispatch => {
return dispatch(receiveErrors(data));
};
export const getOrchestratorInfoSilent = (orchAddr) => async dispatch => {
const response = await apiUtil.getOrchestratorInfo(orchAddr);
const data = await response.json();
if (response.ok) {
if (data && data.id) {
return dispatch(cacheNewOrch(data));
}
}
export const getOrchestratorInfoSilent = async (orchAddr) => {
apiUtil.getOrchestratorInfo(orchAddr);
};
export const getOrchestratorInfo = (orchAddr) => async dispatch => {

View File

@ -95,15 +95,27 @@ const EventButtonAddress = (obj) => {
useEffect(() => {
// Check if cached as an orchestrator
let shouldUpdate = false;
if (livepeer.orchInfo) {
for (const thisOrch of livepeer.orchInfo) {
if (thisOrch.id === obj.address) {
return;
}
}
// Preload Orch info
shouldUpdate = true;
}
if (livepeer.delInfo) {
for (const thisOrch of livepeer.delInfo) {
if (thisOrch.id === obj.address) {
return;
}
}
shouldUpdate = true;
}
// Preload Orch info
if (shouldUpdate){
console.log("Refresh due to non-existing orch in global state");
dispatch(getOrchestratorInfoSilent(obj.address));
getOrchestratorInfoSilent(obj.address);
}
}, [livepeer.orchInfo]);