import { Store as TauriStore } from "@tauri-apps/plugin-store"; type Settings = { server_url: string; user_id: string; private_key: JsonWebKey; friends: ClientFriend[]; is_admin: boolean; }; export const Store = { async get(key: T): Promise { const store = await TauriStore.load("settings.json"); const value = await store.get(key); if (value === undefined) { alert(`Key ${key} not found in store`); throw new Error(`Key ${key} not found in store`); } return value; }, async set(key: T, value: Settings[T]): Promise { const store = await TauriStore.load("settings.json"); await store.set(key, value); await store.save(); }, async isLoggedIn(): Promise { const store = await TauriStore.load("settings.json"); const user_id = await store.get("user_id"); return user_id !== undefined; }, };