From f65cee80a47f093dbdc51fc26ace8d92b99b4f07 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Fri, 31 Jan 2025 20:29:28 -0500 Subject: feat: add try, catch, logging non success to InstalledGamesSection --- src/index.tsx | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/index.tsx') diff --git a/src/index.tsx b/src/index.tsx index fb4d3ae..52c3128 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -169,17 +169,23 @@ function InstalledGamesSection() { useEffect(() => { const fetchGames = async () => { - const result = await listInstalledGames(); - if (result.status === "success") { - const sortedGames = [...result.games] - .map(game => ({ - ...game, - appid: parseInt(game.appid, 10), // Convert string to number - })) - .sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())); - setGames(sortedGames); - } else { - console.error("Failed to fetch games"); + try { + const response = await listInstalledGames(); + console.log("listInstalledGames response:", response); + if (response.status === "success") { + const sortedGames = [...response.games] + .map(game => ({ + ...game, + appid: parseInt(game.appid, 10), // Convert string to number + })) + .sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())); + console.log("Fetched games successfully:", sortedGames.length); + setGames(sortedGames); + } else { + console.error("Failed to fetch games:", response); + } + } catch (error) { + console.error("Error fetching games:", error); } }; -- cgit v1.2.3