blob: 0bd00c090f142d764fec452a43126d9d1eea1f59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import { definePlugin } from "@decky/api";
import { RiAiGenerate } from "react-icons/ri";
import { useState, useEffect } from "react";
import { FGModInstallerSection } from "./components/FGModInstallerSection";
import { InstalledGamesSection } from "./components/InstalledGamesSection";
import { DocumentationButton } from "./components/DocumentationButton";
import { checkFGModPath } from "./api";
import { safeAsyncOperation } from "./utils";
import { TIMEOUTS } from "./utils/constants";
function MainContent() {
const [pathExists, setPathExists] = useState<boolean | null>(null);
useEffect(() => {
const checkPath = async () => {
const result = await safeAsyncOperation(
async () => await checkFGModPath(),
'MainContent -> checkPath'
);
if (result) setPathExists(result.exists);
};
checkPath(); // Initial check
const intervalId = setInterval(checkPath, TIMEOUTS.pathCheck); // Check every 3 seconds
return () => clearInterval(intervalId); // Cleanup interval on component unmount
}, []);
return (
<>
<FGModInstallerSection pathExists={pathExists} setPathExists={setPathExists} />
{pathExists === true ? (
<>
<InstalledGamesSection />
<DocumentationButton />
</>
) : null}
</>
);
}
export default definePlugin(() => ({
name: "Framegen Plugin",
titleView: <div>Decky Framegen</div>,
alwaysRender: true,
content: <MainContent />,
icon: <RiAiGenerate />,
onDismount() {
console.log("Framegen Plugin unmounted");
},
}));
|