import { Store as TauriStore } from "@tauri-apps/plugin-store"; type Settings = { server_url: string; user_id: string; friends: { name: string; id: string }[]; is_admin: boolean; priv_key: string; }; 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; }, // FOR TESTING ONLY async reset(): Promise { const store = await TauriStore.load("settings.json"); await store.reset(); await store.save(); }, };