import { useEffect } from "react";
import { PanelSection, showModal, ButtonItem, PanelSectionRow } from "@decky/ui";
import { useInstallationStatus, useDllDetection, useLsfgConfig } from "../hooks/useLsfgHooks";
import { useProfileManagement } from "../hooks/useProfileManagement";
import { useInstallationActions } from "../hooks/useInstallationActions";
import { StatusDisplay } from "./StatusDisplay";
import { InstallationButton } from "./InstallationButton";
import { ConfigurationSection } from "./ConfigurationSection";
import { ProfileManagement } from "./ProfileManagement";
import { UsageInstructions } from "./UsageInstructions";
import { WikiButton } from "./WikiButton";
import { ClipboardButton } from "./ClipboardButton";
import { SmartClipboardButton } from "./SmartClipboardButton";
import { PluginUpdateChecker } from "./PluginUpdateChecker";
import { NerdStuffModal } from "./NerdStuffModal";
import { ConfigurationData } from "../config/configSchema";
export function Content() {
const {
isInstalled,
installationStatus,
setIsInstalled,
setInstallationStatus
} = useInstallationStatus();
const { dllDetected, dllDetectionStatus } = useDllDetection();
const {
config,
loadLsfgConfig,
updateField
} = useLsfgConfig();
const {
currentProfile,
updateProfileConfig,
loadProfiles
} = useProfileManagement();
const { isInstalling, isUninstalling, handleInstall, handleUninstall } = useInstallationActions();
// Reload config when installation status changes
useEffect(() => {
if (isInstalled) {
loadLsfgConfig();
}
}, [isInstalled, loadLsfgConfig]);
// Generic configuration change handler
const handleConfigChange = async (fieldName: keyof ConfigurationData, value: boolean | number | string) => {
// If we have a current profile, update that profile specifically
if (currentProfile) {
const newConfig = { ...config, [fieldName]: value };
const result = await updateProfileConfig(currentProfile, newConfig);
if (result.success) {
// Reload config to reflect the changes from the backend
await loadLsfgConfig();
}
} else {
// Fallback to the original method for backward compatibility
await updateField(fieldName, value);
}
};
const onInstall = () => {
handleInstall(setIsInstalled, setInstallationStatus, loadLsfgConfig);
};
const onUninstall = () => {
handleUninstall(setIsInstalled, setInstallationStatus);
};
const handleShowNerdStuff = () => {
showModal();
};
return (
{/* Configuration Section - only show if installed */}
{isInstalled && (
)}
{/* Profile Management - only show if installed */}
{isInstalled && (
{
await loadProfiles();
await loadLsfgConfig();
}}
/>
)}
{/* Plugin Update Checker */}
{/* Nerd Stuff Button */}
Nerd Stuff
);
}