mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-10 20:51:58 +00:00
6e3c05072c
* add settings utils to use settings outside of components * initial implementation of developer menu * ✨ Add support for addScriptToEvaluateOnNewDocument * React DevTools support * increase chance of RDT successfully injecting * Rewrite toaster hook to not re-create the window * remove friends focus workaround because it's fixed * Expose various DFL utilities as DFL in dev mode * try to fix text field focuss * move focusable to outside field * add onTouchEnd and onClick to focusable * Update pnpm-lock.yaml Co-authored-by: FinalDoom <7464170-FinalDoom@users.noreply.gitlab.com> Co-authored-by: TrainDoctor <traindoctor@protonmail.com>
23 lines
494 B
TypeScript
23 lines
494 B
TypeScript
import { useEffect, useState } from 'react';
|
|
|
|
import { getSetting, setSetting } from '../settings';
|
|
|
|
export function useSetting<T>(key: string, def: T): [value: T, setValue: (value: T) => Promise<void>] {
|
|
const [value, setValue] = useState(def);
|
|
|
|
useEffect(() => {
|
|
(async () => {
|
|
const res = await getSetting<T>(key, def);
|
|
setValue(res);
|
|
})();
|
|
}, []);
|
|
|
|
return [
|
|
value,
|
|
async (val: T) => {
|
|
setValue(val);
|
|
await setSetting(key, val);
|
|
},
|
|
];
|
|
}
|