From 4c9305e66fbd84d5bd3f02414ed17eb3864b0454 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Mon, 26 Dec 2022 12:12:55 +0000 Subject: [PATCH] feat: hide displayVersion on err --- client/src/app/routes/GameRoutes.tsx | 56 +++++++++++++++------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/client/src/app/routes/GameRoutes.tsx b/client/src/app/routes/GameRoutes.tsx index c8a1415fe..9783af583 100644 --- a/client/src/app/routes/GameRoutes.tsx +++ b/client/src/app/routes/GameRoutes.tsx @@ -278,38 +278,42 @@ function SongInfoHeader({ ) ); - let ImageCell = null; + const [ImageCell, setImageCell] = useState(null); - if (game === "popn") { - ImageCell = ( - ).data.inGameID - }.png` - )} - className="w-100" - /> - ); - } else if (game === "itg") { - const banner = (song as SongDocument<"itg">).data.banner; - - if (banner) { - ImageCell = ( + useEffect(() => { + if (game === "popn") { + setImageCell( ).data.inGameID + }.png` + )} + className="w-100" + /> + ); + } else if (game === "itg") { + const banner = (song as SongDocument<"itg">).data.banner; + + if (banner) { + setImageCell( + + ); + } + } else if ("displayVersion" in song.data) { + setImageCell( + setImageCell(null)} + src={ToCDNURL(`/game-icons/${game}/${song.data.displayVersion}`)} className="w-100" /> ); } - } else if ("displayVersion" in song.data) { - ImageCell = ( - - ); - } + }, [game, song]); return (