Refactor state system #7

This commit is contained in:
2026-04-04 22:04:53 +02:00
parent faf3e4ffef
commit 02454625d6
5 changed files with 112 additions and 58 deletions
+9 -1
View File
@@ -7,6 +7,7 @@ import SettingsSection from "./components/SettingsSection";
import { versions } from "./lib/launcher";
import { GameVersion } from "./lib/types";
import { MinecraftAccount } from "./lib/auth";
import { getVersion, updateVersion } from "./lib/saturn";
type Section = "play" | "mods" | "settings";
@@ -50,9 +51,16 @@ export default function App() {
}, []);
useEffect(() => {
setSelectedVersion(versions[0]);
(async () => {
const version = await getVersion();
setSelectedVersion(versions.find((v) => v.id == version) || null);
})();
}, []);
useEffect(() => {
if (selectedVersion?.id) updateVersion(selectedVersion?.id);
}, [selectedVersion]);
return (
<div className="flex h-screen">
<Sidebar active={active} setActive={setActive} />
+9
View File
@@ -65,3 +65,12 @@ export async function updateSettings(
): Promise<void> {
await invoke("update_settings", { newSettings });
}
// --- Version ---
export async function getVersion(): Promise<string> {
return await invoke("get_version");
}
export async function updateVersion(version: string): Promise<void> {
await invoke("update_version", { version });
}