From 739f9741372dedc3240ca735009e6516f844259b Mon Sep 17 00:00:00 2001 From: Mikael Lindlof Date: Sat, 12 Dec 2020 10:21:24 +0000 Subject: [PATCH] Improvements on slow connection --- web/src/components/GameTicker.tsx | 4 ++-- web/src/wallet/useAccount.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/src/components/GameTicker.tsx b/web/src/components/GameTicker.tsx index 31684a8..40028c0 100644 --- a/web/src/components/GameTicker.tsx +++ b/web/src/components/GameTicker.tsx @@ -19,8 +19,8 @@ const GameTicker = (props: React.PropsWithChildren) => { update = await Game.tick(client, game); } catch {} if (update === undefined) return; - setGame((g: Game.Game): Game.Game | undefined => { - if (!update) return; + setGame((g: Game.Game | undefined): Game.Game | undefined => { + if (g === undefined || !update) return; return { ...g, ...update }; }); }, 2000); diff --git a/web/src/wallet/useAccount.ts b/web/src/wallet/useAccount.ts index ffb0e62..576102b 100644 --- a/web/src/wallet/useAccount.ts +++ b/web/src/wallet/useAccount.ts @@ -10,8 +10,8 @@ const useAccount = ( useEffect(() => { if (!client) return; getAccount(client, setAccount); - const interval = setInterval(() => { - getAccount(client, setAccount); + const interval = setInterval(async () => { + await getAccount(client, setAccount); }, 10000); return () => clearInterval(interval); }, [client, refreshOn]);