blob: 3e5d2d0cf252c4f46dda2d3b6c966692c5ef58bc (
plain) (
blame)
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
|
import { create } from "zustand/react";
import { detectJava, refreshJavaCatalog } from "@/client";
import type { JavaCatalog, JavaInstallation } from "@/types";
export interface JavaState {
catalog: JavaCatalog | null;
installations: JavaInstallation[] | null;
refresh: () => Promise<void>;
refreshInstallations: () => Promise<void>;
}
export const useJavaStore = create<JavaState>((set) => ({
catalog: null,
installations: null,
refresh: async () => {
const catalog = await refreshJavaCatalog();
set({ catalog });
},
refreshInstallations: async () => {
const installations = await detectJava();
set({ installations });
},
}));
|