From 8ae259e143ec251506348acd280ba1f557d1366f Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sat, 13 Jan 2024 12:43:17 +0000 Subject: [PATCH] Re-set fetchOrder on page change, empty book on not_found --- frontend/src/contexts/FederationContext.tsx | 9 +++------ frontend/src/models/Coordinator.model.ts | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/contexts/FederationContext.tsx b/frontend/src/contexts/FederationContext.tsx index 5e4336553..1ddbccf7f 100644 --- a/frontend/src/contexts/FederationContext.tsx +++ b/frontend/src/contexts/FederationContext.tsx @@ -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); } @@ -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)); }; @@ -141,7 +139,7 @@ export const FederationContextProvider = ({ onOrderReceived(order as Order); }); } else { - console.log('Hit no order, delay', defaultDelay); + clearInterval(timer); setTimer(setTimeout(fetchCurrentOrder, defaultDelay)); } }; @@ -149,11 +147,10 @@ export const FederationContextProvider = ({ useEffect(() => { clearInterval(timer); fetchCurrentOrder(); - setDelay(defaultDelay); return () => { clearInterval(timer); }; - }, [coordinatorUpdatedAt, federationUpdatedAt]); + }, [page]); useEffect(() => { if (page === 'offers') void federation.updateBook(); diff --git a/frontend/src/models/Coordinator.model.ts b/frontend/src/models/Coordinator.model.ts index a1a7db98b..0d8cf2c47 100644 --- a/frontend/src/models/Coordinator.model.ts +++ b/frontend/src/models/Coordinator.model.ts @@ -193,6 +193,9 @@ export class Coordinator { }); void this.generateAllMakerAvatars(data); onDataLoad(); + } else { + this.book = []; + onDataLoad(); } }) .catch((e) => {