mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 18:55:09 +02:00
Make silent preload of orchestrator info not modify local browser cache and also look at delegator cache before preloading
This commit is contained in:
parent
9cd691afae
commit
e69338ed5f
@ -146,14 +146,8 @@ export const getCurrentOrchestratorInfo = () => async dispatch => {
|
|||||||
return dispatch(receiveErrors(data));
|
return dispatch(receiveErrors(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getOrchestratorInfoSilent = (orchAddr) => async dispatch => {
|
export const getOrchestratorInfoSilent = async (orchAddr) => {
|
||||||
const response = await apiUtil.getOrchestratorInfo(orchAddr);
|
apiUtil.getOrchestratorInfo(orchAddr);
|
||||||
const data = await response.json();
|
|
||||||
if (response.ok) {
|
|
||||||
if (data && data.id) {
|
|
||||||
return dispatch(cacheNewOrch(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getOrchestratorInfo = (orchAddr) => async dispatch => {
|
export const getOrchestratorInfo = (orchAddr) => async dispatch => {
|
||||||
|
@ -95,15 +95,27 @@ const EventButtonAddress = (obj) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Check if cached as an orchestrator
|
// Check if cached as an orchestrator
|
||||||
|
let shouldUpdate = false;
|
||||||
if (livepeer.orchInfo) {
|
if (livepeer.orchInfo) {
|
||||||
for (const thisOrch of livepeer.orchInfo) {
|
for (const thisOrch of livepeer.orchInfo) {
|
||||||
if (thisOrch.id === obj.address) {
|
if (thisOrch.id === obj.address) {
|
||||||
return;
|
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");
|
console.log("Refresh due to non-existing orch in global state");
|
||||||
dispatch(getOrchestratorInfoSilent(obj.address));
|
getOrchestratorInfoSilent(obj.address);
|
||||||
}
|
}
|
||||||
}, [livepeer.orchInfo]);
|
}, [livepeer.orchInfo]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user