Skip to content

Commit

Permalink
invalidate queries when server is back online (#1884)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ptrhnk authored Nov 3, 2023
1 parent ee8ecbb commit 5d26ed4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/client/src/components/advanced/PageHeader/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,17 @@ export const LeftHeader: React.FC<LeftHeader> = React.memo(
const ping: number = useAppSelector((state) => state.ping);

const [pingColor, setPingColor] = useState<keyof PingColor>("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");
Expand Down Expand Up @@ -113,8 +122,8 @@ export const LeftHeader: React.FC<LeftHeader> = React.memo(
{ping === -10 && (
<BeatLoader
size={6}
margin={5}
style={{ marginLeft: "0.2rem", marginTop: "0.1rem" }}
margin={4}
style={{ marginLeft: "0.3rem", marginTop: "0.1rem" }}
color="white"
/>
)}
Expand Down

0 comments on commit 5d26ed4

Please sign in to comment.