JS -> Python WS now functional

This commit is contained in:
AAGaming
2023-07-10 18:41:56 -04:00
committed by marios8543
parent 05b41b3410
commit 1921e7ec56
7 changed files with 112 additions and 73 deletions
+3 -19
View File
@@ -1,24 +1,8 @@
interface GetSettingArgs<T> {
key: string;
default: T;
}
interface SetSettingArgs<T> {
key: string;
value: T;
}
export async function getSetting<T>(key: string, def: T): Promise<T> {
const res = (await window.DeckyPluginLoader.callServerMethod('get_setting', {
key,
default: def,
} as GetSettingArgs<T>)) as { result: T };
return res.result;
const res = await window.DeckyPluginLoader.ws.call<[string, T], T>('utilities/settings/get', key, def);
return res;
}
export async function setSetting<T>(key: string, value: T): Promise<void> {
await window.DeckyPluginLoader.callServerMethod('set_setting', {
key,
value,
} as SetSettingArgs<T>);
await window.DeckyPluginLoader.ws.call<[string, T], void>('utilities/settings/set', key, value);
}