From f37a3fbb675e1d4fa87d92aedee152cb23b4a7f3 Mon Sep 17 00:00:00 2001 From: rsproule Date: Wed, 3 Jan 2024 14:21:18 -0500 Subject: [PATCH] nit: frontend error path clean --- frontend/src/app/game/[gameId]/GamePage.tsx | 8 ++++++-- frontend/src/app/games/page.tsx | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/game/[gameId]/GamePage.tsx b/frontend/src/app/game/[gameId]/GamePage.tsx index c024dac..8d560cf 100644 --- a/frontend/src/app/game/[gameId]/GamePage.tsx +++ b/frontend/src/app/game/[gameId]/GamePage.tsx @@ -2,6 +2,7 @@ import { EventStream } from "@/src/components/tankGame/EventsStream"; import { TankGame } from "@/src/components/tankGame/TankGame"; +import { Button } from "@/src/components/ui/button"; import { Toaster } from "@/src/components/ui/toaster"; import { gameViewAddress, useGameViewGetSettings } from "@/src/generated"; import Link from "next/link"; @@ -45,8 +46,11 @@ export function GamePage({ gameAddress }: { gameAddress: `0x${string}` }) { }} > Game not found at address: {gameAddress} -
- Back to Games +
+ + + +
); } diff --git a/frontend/src/app/games/page.tsx b/frontend/src/app/games/page.tsx index f0e65f7..ee62c31 100644 --- a/frontend/src/app/games/page.tsx +++ b/frontend/src/app/games/page.tsx @@ -6,7 +6,7 @@ import { useTankGamePlayersCount, } from "@/src/generated"; import { useEffect, useState } from "react"; -import { Address, useBalance, useBlockNumber, useNetwork } from "wagmi"; +import { Address, useAccount, useBalance, useBlockNumber, useNetwork } from "wagmi"; import { getPublicClient } from "wagmi/actions"; import CreateGameForm from "@/src/components/CreateGameForm"; import { @@ -26,6 +26,7 @@ import { Button } from "@/src/components/ui/button"; export default function GamesList() { const { data: blockNumber } = useBlockNumber({ watch: true }); + const { address } = useAccount(); const [games, setGames] = useState(); const { chain } = useNetwork(); const getLogs = async () => { @@ -51,7 +52,10 @@ export default function GamesList() { }) .catch(console.error); }, [blockNumber]); - console.log({ games }); + + if (!address) { + return
Connect your wallet to see games.
; + } return (