Skip to content

Commit

Permalink
Re-set fetchOrder on page change, empty book on not_found
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed Jan 13, 2024
1 parent af3007b commit 8ae259e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 3 additions & 6 deletions frontend/src/contexts/FederationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export const FederationContextProvider = ({
let newDelay = defaultDelay;
if (order?.bad_request) {
newDelay = 99999999;
console.log('bad request on order, new delay', newDelay);
setBadOrder(order.bad_request);
garage.updateOrder(null);
}
Expand All @@ -123,11 +122,10 @@ export const FederationContextProvider = ({
? statusToDelay[order.status]
: statusToDelay[order.status] * 5 // If user is not looking at "order" tab, refresh less often.
: 99999999;
console.log('has order id, new delay is', newDelay);
garage.updateOrder(order);
setBadOrder(undefined);
}
console.log('setting delay!', newDelay);
clearInterval(timer);
setDelay(newDelay);
setTimer(setTimeout(fetchCurrentOrder, newDelay));
};
Expand All @@ -141,19 +139,18 @@ export const FederationContextProvider = ({
onOrderReceived(order as Order);
});
} else {
console.log('Hit no order, delay', defaultDelay);
clearInterval(timer);
setTimer(setTimeout(fetchCurrentOrder, defaultDelay));
}
};

useEffect(() => {
clearInterval(timer);
fetchCurrentOrder();
setDelay(defaultDelay);
return () => {
clearInterval(timer);
};
}, [coordinatorUpdatedAt, federationUpdatedAt]);
}, [page]);

useEffect(() => {
if (page === 'offers') void federation.updateBook();
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/models/Coordinator.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ export class Coordinator {
});
void this.generateAllMakerAvatars(data);
onDataLoad();
} else {
this.book = [];
onDataLoad();
}
})
.catch((e) => {
Expand Down

0 comments on commit 8ae259e

Please sign in to comment.