From 5d40bc1aac21d07c8af16615d8311e679ef50667 Mon Sep 17 00:00:00 2001
From: xXJSONDeruloXx <danielhimebauch@gmail.com>
Date: Sun, 26 Jan 2025 15:17:01 -0500
Subject: groundwork for games list, next step patch on button press

---
 src/index.tsx | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index f7e1f24..b2586dc 100755
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -23,6 +23,11 @@ const checkFGModPath = callable<
   { exists: boolean }
 >("check_fgmod_path");
 
+const listInstalledGames = callable<
+  [],
+  { status: string; games: { appid: string; name: string }[] }
+>("list_installed_games");
+
 function FGModInstallerSection() {
   const [installing, setInstalling] = useState(false);
   const [uninstalling, setUninstalling] = useState(false);
@@ -225,6 +230,35 @@ function MainRunningApp() {
   );
 }
 
+function InstalledGamesSection() {
+  const [games, setGames] = useState<{ appid: string; name: string }[]>([]);
+
+  useEffect(() => {
+    const fetchGames = async () => {
+      const result = await listInstalledGames();
+      if (result.status === "success") {
+        setGames(result.games);
+      } else {
+        console.error("Failed to fetch games");
+      }
+    };
+
+    fetchGames();
+  }, []);
+
+  return (
+    <PanelSection title="Installed Games">
+      {games.map((game) => (
+        <PanelSectionRow key={game.appid}>
+          <ButtonItem layout="below">
+            {game.name} (AppID: {game.appid})
+          </ButtonItem>
+        </PanelSectionRow>
+      ))}
+    </PanelSection>
+  );
+}
+
 export default definePlugin(() => ({
   name: "Framegen Plugin",
   titleView: <div>Decky Framegen</div>,
@@ -233,6 +267,7 @@ export default definePlugin(() => ({
     <>
       <FGModInstallerSection />
       <MainRunningApp />
+      <InstalledGamesSection />
       <MainContent />
     </>
   ),
-- 
cgit v1.2.3

