From 5d26ed4c36ed52a0fb895737e5d21269aff4d05f Mon Sep 17 00:00:00 2001 From: Ptrhnk Date: Fri, 3 Nov 2023 13:00:47 +0100 Subject: [PATCH] invalidate queries when server is back online (#1884) --- .../components/advanced/PageHeader/PageHeader.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/advanced/PageHeader/PageHeader.tsx b/packages/client/src/components/advanced/PageHeader/PageHeader.tsx index bedf700c9..7763bb74e 100644 --- a/packages/client/src/components/advanced/PageHeader/PageHeader.tsx +++ b/packages/client/src/components/advanced/PageHeader/PageHeader.tsx @@ -47,8 +47,17 @@ export const LeftHeader: React.FC = React.memo( const ping: number = useAppSelector((state) => state.ping); const [pingColor, setPingColor] = useState("0"); + const [waitingForServerRestart, setWaitingForServerRestart] = + useState(false); useEffect(() => { + if ((ping === -1 || ping === -2) && !waitingForServerRestart) { + setWaitingForServerRestart(true); + } else if (ping >= 0 && waitingForServerRestart) { + queryClient.invalidateQueries(); + setWaitingForServerRestart(false); + } + switch (true) { case ping === -2: setPingColor("-2"); @@ -113,8 +122,8 @@ export const LeftHeader: React.FC = React.memo( {ping === -10 && ( )}