Skip to content

Commit

Permalink
Stop updating game once over
Browse files Browse the repository at this point in the history
  • Loading branch information
lindlof committed Dec 13, 2020
1 parent 739f974 commit 6231ff5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions web/src/components/GameTicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ const GameTicker = (props: React.PropsWithChildren<Props>) => {
useEffect(() => {
if (!client || !game) return;
const timer = setInterval(async () => {
if (game.stage === Game.Stage.Over) return;
let update: Game.TickUpdate | undefined;
try {
update = await Game.tick(client, game);
} catch {}
if (update === undefined) return;
setGame((g: Game.Game | undefined): Game.Game | undefined => {
if (g === undefined || !update) return;
if (g.locator !== game.locator) return;
return { ...g, ...update };
});
}, 2000);
Expand Down

0 comments on commit 6231ff5

Please sign in to comment.