From 7a55e4d8b19c0b149948aff25f09892bb9792f14 Mon Sep 17 00:00:00 2001 From: Type-Style Date: Fri, 19 Jul 2024 21:04:54 +0200 Subject: [PATCH] [Fix] #93, offline message improvement (#96) --- src/client/pages/Start.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/pages/Start.tsx b/src/client/pages/Start.tsx index 8d91287..5a4bd91 100644 --- a/src/client/pages/Start.tsx +++ b/src/client/pages/Start.tsx @@ -88,11 +88,21 @@ function Start() { setMessageObj({ isError: null, status: null, message: null }); setNextFetch(new Date().getTime() + fetchIntervalMs); } catch (error) { + console.log("error fetching data %o", error); + + if (!error.response) { + setMessageObj({ isError: true, status: 499, message: error.message || "offline" }); + setNextFetch(new Date().getTime() + fetchIntervalMs); + return; + } + + if (error.response.status == 403) { setLogin(false) } + + setMessageObj({ isError: true, status: error.response.data.status || error.response.status, message: error.response.data.message || error.message }); + clearInterval(intervalID.current); intervalID.current = null; console.info("cleared Interval"); setNextFetch(null); - if (error.response.status == 403) { setLogin(false) } - setMessageObj({ isError: true, status: error.response.data.status || error.response.status, message: error.response.data.message || error.message }); } };